Skip to content

Commit

Permalink
further separate react-router
Browse files Browse the repository at this point in the history
  • Loading branch information
gtibrett committed Mar 12, 2024
1 parent 2ed948b commit b4b322a
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 70 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
57 changes: 0 additions & 57 deletions src/Link.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<>
<BrowserRouter>
<Link component={LinkBehavior} href="/">Home</Link>
</BrowserRouter>
</>);

expect(screen.getByText(/home/i)).toBeInTheDocument();
});

test('Plain React Router Link: primary color', async () => {
render(<>
<BrowserRouter>
<Link component={LinkBehavior} href="/" color="primary">Home</Link>
</BrowserRouter>
</>);

expect(screen.getByText(/home/i)).toBeInTheDocument();
});

test('Plain React Router Link: inherit color', async () => {
render(<>
<BrowserRouter>
<Link component={LinkBehavior} href="/" color="inherit">Home</Link>
</BrowserRouter>
</>);

expect(screen.getByText(/home/i)).toBeInTheDocument();
});

describe('Plain React Router Link: a11y', () => {
testForAccessibility(
<BrowserRouter>
<Link component={LinkBehavior} href="/">Home</Link>
</BrowserRouter>
);
});

test('Plain Mui Link: render', async () => {
render(<>
<BrowserRouter>
Expand All @@ -61,24 +22,6 @@ describe('Link.tsx', () => {
);
});

test('External React Router Link: render', async () => {
render(<>
<BrowserRouter>
<Link component={LinkBehavior} href="/" target="_blank">Home</Link>
</BrowserRouter>
</>);

expect(screen.getByText(/home/i)).toBeInTheDocument();
});

describe('External React Router Link: a11y', () => {
testForAccessibility(
<BrowserRouter>
<Link component={LinkBehavior} href="/" target="_blank">Home</Link>
</BrowserRouter>
);
});

test('External Mui Link: render', async () => {
render(<>
<BrowserRouter>
Expand Down
11 changes: 2 additions & 9 deletions src/UkraineButton.test.tsx
Original file line number Diff line number Diff line change
@@ -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(<>
<BrowserRouter>
<UkraineButton/>
</BrowserRouter>
</>);
render(<UkraineButton/>);

expect(screen.getByLabelText(/Stand with Ukraine/i)).toBeInTheDocument();
});

describe('a11y check', () => {
testForAccessibility(
<BrowserRouter>
<UkraineButton/>
</BrowserRouter>
<UkraineButton/>
);
});
});
2 changes: 0 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
File renamed without changes.
63 changes: 63 additions & 0 deletions src/react-router/LinkBehavior.test.tsx
Original file line number Diff line number Diff line change
@@ -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(<>
<BrowserRouter>
<Link component={LinkBehavior} href="/">Home</Link>
</BrowserRouter>
</>);

expect(screen.getByText(/home/i)).toBeInTheDocument();
});

test('Plain React Router Link: primary color', async () => {
render(<>
<BrowserRouter>
<Link component={LinkBehavior} href="/" color="primary">Home</Link>
</BrowserRouter>
</>);

expect(screen.getByText(/home/i)).toBeInTheDocument();
});

test('Plain React Router Link: inherit color', async () => {
render(<>
<BrowserRouter>
<Link component={LinkBehavior} href="/" color="inherit">Home</Link>
</BrowserRouter>
</>);

expect(screen.getByText(/home/i)).toBeInTheDocument();
});

describe('Plain React Router Link: a11y', () => {
testForAccessibility(
<BrowserRouter>
<Link component={LinkBehavior} href="/">Home</Link>
</BrowserRouter>
);
});

test('External React Router Link: render', async () => {
render(<>
<BrowserRouter>
<Link component={LinkBehavior} href="/" target="_blank">Home</Link>
</BrowserRouter>
</>);

expect(screen.getByText(/home/i)).toBeInTheDocument();
});

describe('External React Router Link: a11y', () => {
testForAccessibility(
<BrowserRouter>
<Link component={LinkBehavior} href="/" target="_blank">Home</Link>
</BrowserRouter>
);
});
});
File renamed without changes.
2 changes: 2 additions & 0 deletions src/react-router/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {default as GoogleAnalyticsProvider} from './GoogleAnalyticsProvider';
export {default as LinkBehavior} from './LinkBehavior';

0 comments on commit b4b322a

Please sign in to comment.