mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-14 00:32:35 +10:00
Builder: updated unit test handling non-existent resume
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import Constants from '../constants/auth';
|
import Constants from '../constants/auth';
|
||||||
import delay from '../utils/index';
|
import delay from '../../utils/index';
|
||||||
|
|
||||||
const singleton = Symbol('');
|
const singleton = Symbol('');
|
||||||
const singletonEnforcer = Symbol('');
|
const singletonEnforcer = Symbol('');
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { v4 as uuidv4 } from 'uuid';
|
|||||||
|
|
||||||
import DatabaseConstants from '../constants/database';
|
import DatabaseConstants from '../constants/database';
|
||||||
import DataSnapshot from './dataSnapshot';
|
import DataSnapshot from './dataSnapshot';
|
||||||
import delay from '../utils/index';
|
import delay from '../../utils/index';
|
||||||
|
|
||||||
const parsePath = (path) => {
|
const parsePath = (path) => {
|
||||||
if (!path) {
|
if (!path) {
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import delay from './utils/index';
|
||||||
|
|
||||||
const Gatsby = jest.requireActual('gatsby');
|
const Gatsby = jest.requireActual('gatsby');
|
||||||
|
|
||||||
const fluidImageShapes = [
|
const fluidImageShapes = [
|
||||||
@ -67,6 +69,14 @@ const useStaticQuery = () => ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const defaultDelayInMilliseconds = 100;
|
||||||
|
|
||||||
|
const navigate = async () => {
|
||||||
|
await delay(defaultDelayInMilliseconds);
|
||||||
|
|
||||||
|
return Promise.resolve();
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
...Gatsby,
|
...Gatsby,
|
||||||
graphql: jest.fn(),
|
graphql: jest.fn(),
|
||||||
@ -76,6 +86,6 @@ module.exports = {
|
|||||||
href: to,
|
href: to,
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
navigate: jest.fn(),
|
navigate: jest.fn(navigate),
|
||||||
useStaticQuery,
|
useStaticQuery,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -89,15 +89,27 @@ describe('Builder', () => {
|
|||||||
|
|
||||||
describe('handles errors', () => {
|
describe('handles errors', () => {
|
||||||
describe('if resume does not exist', () => {
|
describe('if resume does not exist', () => {
|
||||||
|
const waitForNavigateFunctionToHaveCompleted = async () => {
|
||||||
|
await waitFor(() => mockNavigateFunction.mock.results[0].value);
|
||||||
|
};
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await setup('xxxxxx', false, false);
|
await setup('xxxxxx', false, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('navigates to Dashboard', async () => {
|
afterEach(async () => {
|
||||||
|
await waitForNavigateFunctionToHaveCompleted();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('navigates to Dashboard and displays notification', async () => {
|
||||||
await waitFor(() =>
|
await waitFor(() =>
|
||||||
expect(mockNavigateFunction).toHaveBeenCalledTimes(1),
|
expect(mockNavigateFunction).toHaveBeenCalledTimes(1),
|
||||||
);
|
);
|
||||||
expect(mockNavigateFunction).toHaveBeenCalledWith('/app/dashboard');
|
expect(mockNavigateFunction).toHaveBeenCalledWith('/app/dashboard');
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(screen.getByRole('alert')).toBeInTheDocument();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user