diff --git a/package.json b/package.json index 87c4685..0e430c6 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ }, "exports": { ".": "./index.js", - "./jest": "./jest/index.js" + "./jest": "./jest/index.js", + "./react-router": "./react-router/index.js" }, "types": "index.d.ts", "scripts": { diff --git a/src/Link.test.tsx b/src/Link.test.tsx index 6ec69e9..0cb0078 100644 --- a/src/Link.test.tsx +++ b/src/Link.test.tsx @@ -2,47 +2,8 @@ import {render, screen} from '@testing-library/react'; import {BrowserRouter} from 'react-router-dom'; import {testForAccessibility} from './jest'; import Link from './Link'; -import LinkBehavior from './LinkBehavior'; describe('Link.tsx', () => { - test('Plain React Router Link: render', async () => { - render(<> - - Home - - ); - - expect(screen.getByText(/home/i)).toBeInTheDocument(); - }); - - test('Plain React Router Link: primary color', async () => { - render(<> - - Home - - ); - - expect(screen.getByText(/home/i)).toBeInTheDocument(); - }); - - test('Plain React Router Link: inherit color', async () => { - render(<> - - Home - - ); - - expect(screen.getByText(/home/i)).toBeInTheDocument(); - }); - - describe('Plain React Router Link: a11y', () => { - testForAccessibility( - - Home - - ); - }); - test('Plain Mui Link: render', async () => { render(<> @@ -61,24 +22,6 @@ describe('Link.tsx', () => { ); }); - test('External React Router Link: render', async () => { - render(<> - - Home - - ); - - expect(screen.getByText(/home/i)).toBeInTheDocument(); - }); - - describe('External React Router Link: a11y', () => { - testForAccessibility( - - Home - - ); - }); - test('External Mui Link: render', async () => { render(<> diff --git a/src/UkraineButton.test.tsx b/src/UkraineButton.test.tsx index e5d9bb3..cee7cff 100644 --- a/src/UkraineButton.test.tsx +++ b/src/UkraineButton.test.tsx @@ -1,24 +1,17 @@ import {render, screen} from '@testing-library/react'; -import {BrowserRouter} from 'react-router-dom'; import {testForAccessibility} from './jest'; import UkraineButton from './UkraineButton'; describe('UkraineButton.tsx', () => { test('Render', async () => { - render(<> - - - - ); + render(); expect(screen.getByLabelText(/Stand with Ukraine/i)).toBeInTheDocument(); }); describe('a11y check', () => { testForAccessibility( - - - + ); }); }); \ No newline at end of file diff --git a/src/index.tsx b/src/index.tsx index 060bed8..e7c54b5 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,8 +1,6 @@ export {default as Breakpoints} from './Breakpoints'; export {default as Dialog} from './Dialog'; -export {default as GoogleAnalyticsProvider} from './GoogleAnalyticsProvider'; export {default as Link} from './Link'; -export {default as LinkBehavior} from './LinkBehavior'; export {default as SkipNav} from './SkipNav'; export {default as Tabs, TabContent} from './Tabs'; export {default as UkraineButton} from './UkraineButton'; diff --git a/src/GoogleAnalyticsProvider.test.tsx b/src/react-router/GoogleAnalyticsProvider.test.tsx similarity index 98% rename from src/GoogleAnalyticsProvider.test.tsx rename to src/react-router/GoogleAnalyticsProvider.test.tsx index 5dec197..2fe4b9e 100644 --- a/src/GoogleAnalyticsProvider.test.tsx +++ b/src/react-router/GoogleAnalyticsProvider.test.tsx @@ -2,8 +2,8 @@ import {render, screen} from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import ReactGA from 'react-ga4'; import {MemoryRouter} from 'react-router-dom'; +import Link from '../Link'; import GoogleAnalyticsProvider from './GoogleAnalyticsProvider'; -import Link from './Link'; import LinkBehavior from './LinkBehavior'; const GA_TRACKING_ID: string | undefined = 'G-ABCDEFGHI9'; diff --git a/src/GoogleAnalyticsProvider.tsx b/src/react-router/GoogleAnalyticsProvider.tsx similarity index 100% rename from src/GoogleAnalyticsProvider.tsx rename to src/react-router/GoogleAnalyticsProvider.tsx diff --git a/src/react-router/LinkBehavior.test.tsx b/src/react-router/LinkBehavior.test.tsx new file mode 100644 index 0000000..1dbf7e2 --- /dev/null +++ b/src/react-router/LinkBehavior.test.tsx @@ -0,0 +1,63 @@ +import {render, screen} from '@testing-library/react'; +import {BrowserRouter} from 'react-router-dom'; +import {testForAccessibility} from '../jest'; +import Link from '../Link'; +import LinkBehavior from './LinkBehavior'; + +describe('LinkBehavior.tsx', () => { + test('Plain React Router Link: render', async () => { + render(<> + + Home + + ); + + expect(screen.getByText(/home/i)).toBeInTheDocument(); + }); + + test('Plain React Router Link: primary color', async () => { + render(<> + + Home + + ); + + expect(screen.getByText(/home/i)).toBeInTheDocument(); + }); + + test('Plain React Router Link: inherit color', async () => { + render(<> + + Home + + ); + + expect(screen.getByText(/home/i)).toBeInTheDocument(); + }); + + describe('Plain React Router Link: a11y', () => { + testForAccessibility( + + Home + + ); + }); + + test('External React Router Link: render', async () => { + render(<> + + Home + + ); + + expect(screen.getByText(/home/i)).toBeInTheDocument(); + }); + + describe('External React Router Link: a11y', () => { + testForAccessibility( + + Home + + ); + }); +}); \ No newline at end of file diff --git a/src/LinkBehavior.tsx b/src/react-router/LinkBehavior.tsx similarity index 100% rename from src/LinkBehavior.tsx rename to src/react-router/LinkBehavior.tsx diff --git a/src/react-router/index.ts b/src/react-router/index.ts new file mode 100644 index 0000000..c10321c --- /dev/null +++ b/src/react-router/index.ts @@ -0,0 +1,2 @@ +export {default as GoogleAnalyticsProvider} from './GoogleAnalyticsProvider'; +export {default as LinkBehavior} from './LinkBehavior';