Skip to content

Commit

Permalink
test: routes.spec.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
nichita-pasecinic committed Jan 14, 2024
1 parent b38b570 commit f993b7b
Show file tree
Hide file tree
Showing 6 changed files with 425 additions and 112 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ jobs:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- run: npm i
- run: npm run lint && npm run build && npm run publint
- run: npm run lint
- run: npm run test
- run: npm run build
- run: npm run publint
2 changes: 1 addition & 1 deletion src/lib/utils/create-nested-routes.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { RouteProps } from '../types';
import type { FC } from 'react';
import { Route } from 'react-router-dom';
import { isDefined } from '../utils';
import { isDefined } from './index';

export const createNestedRoutes = (RouteType: FC<RouteProps>, routes?: RouteProps[]) => {
if (!isDefined(routes)) return null;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './get-routes-config';
export * from './assert-is-defined';
export * from './create-nested-routes'
export * from './create-nested-routes.tsx'
export * from './is-defined';
5 changes: 5 additions & 0 deletions src/test/__mocks__/page-a.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const pageA = () => {
return <div data-testid={'page_a'} />;
};

export default pageA;
12 changes: 12 additions & 0 deletions src/test/__mocks__/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { lazy } from 'react';

export const getLazyLoadedPageA = (timeout: number) =>
lazy(() => {
return new Promise((resolve) => {
setTimeout(() => {
import('./page-a').then((module) => {
resolve({ default: module.default as never });
});
}, timeout);
});
});
Loading

0 comments on commit f993b7b

Please sign in to comment.