Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
birdofpreyru committed Jan 15, 2025
2 parents 5a062a2 + 08dda22 commit 83703e8
Show file tree
Hide file tree
Showing 21 changed files with 127 additions and 132 deletions.
10 changes: 2 additions & 8 deletions __tests__/shared/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { noop, omit } from 'lodash';
import Button from 'components/Button';
import { snapshot } from 'utils/jest';
import { StaticRouter } from 'react-router-dom/server';
import { StaticRouter } from 'react-router';

const testTheme = {
active: 'ACTIVE_CLASS',
Expand Down Expand Up @@ -48,13 +48,7 @@ describe('Matches snapshots', () => {
});
test('when rendered as link', () => {
snapshot((
<StaticRouter
future={{
v7_relativeSplatPath: true,
v7_startTransition: true,
}}
location=""
>
<StaticRouter location="">
<Button
active
theme={testTheme}
Expand Down
2 changes: 1 addition & 1 deletion __tests__/shared/components/GenericLink.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jest-environment jsdom */

import { Link } from 'react-router-dom';
import { Link } from 'react-router';

import UserEvents from '@testing-library/user-event';

Expand Down
9 changes: 2 additions & 7 deletions __tests__/shared/components/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
/** @jest-environment jsdom */

import { MemoryRouter } from 'react-router-dom';
import { MemoryRouter } from 'react-router';

import Link from 'components/Link';
import { snapshot } from 'utils/jest';

test('Matches snapshots', () => {
snapshot(
<MemoryRouter
future={{
v7_relativeSplatPath: true,
v7_startTransition: true,
}}
>
<MemoryRouter>
<Link to="" />
</MemoryRouter>,
);
Expand Down
16 changes: 3 additions & 13 deletions __tests__/shared/components/NavLink/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jest-environment jsdom */

import { MemoryRouter } from 'react-router-dom';
import { MemoryRouter } from 'react-router';

import NavLink from 'components/NavLink';

Expand All @@ -10,22 +10,12 @@ import './styles.scss';

test('Matches snapshots', () => {
snapshot(
<MemoryRouter
future={{
v7_relativeSplatPath: true,
v7_startTransition: true,
}}
>
<MemoryRouter>
<NavLink to="" />
</MemoryRouter>,
);
snapshot(
<MemoryRouter
future={{
v7_relativeSplatPath: true,
v7_startTransition: true,
}}
>
<MemoryRouter>
<NavLink styleName="navLink" to="" />
</MemoryRouter>,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exports[`Relative link 1`] = `
<button
type="button"
>
{"to":"http/relative/link","children":"RELATIVE LINK"}
{"discover":"none","to":"http/relative/link","children":"RELATIVE LINK"}
</button>
`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Route, Routes } from 'react-router-dom';
import { Route, Routes } from 'react-router';

const Component = () => <div>Hello World!</div>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Route, Routes } from 'react-router-dom';
import { Route, Routes } from 'react-router';
import splitComponent from 'utils/splitComponent';

// Note: this is not exactly how splitComponent() should be used to actually
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { type ReactNode } from 'react';
import { Route, Routes } from 'react-router-dom';
import { Route, Routes } from 'react-router';
import { type ForceT, useGlobalState } from '@dr.pogodin/react-global-state';

import './style.scss';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { type ReactNode } from 'react';
import { Route, Routes } from 'react-router-dom';
import { Route, Routes } from 'react-router';

import { type ForceT, useGlobalState } from '@dr.pogodin/react-global-state';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { type ReactNode } from 'react';
import { Route, Routes } from 'react-router-dom';
import { Route, Routes } from 'react-router';

import { type ForceT, useGlobalState } from '@dr.pogodin/react-global-state';

Expand Down
8 changes: 5 additions & 3 deletions config/jest/resolver.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module.exports = (path, options) => {
const ops = { ...options };

// Appending "development" option we ensure that Jest tests use development
// version of the library's build for browsers, which for example contains
// "data-testid" attributes (they are optimized-out of production builds).
if (options.conditions && !options.conditions.includes('development')) {
options.conditions.push('development');
if (ops.conditions && !ops.conditions.includes('development')) {
ops.conditions = [...ops.conditions, 'development'];
}

return options.defaultResolver(path, { ...options });
return options.defaultResolver(path, ops);
};
12 changes: 11 additions & 1 deletion config/jest/setup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable global-require, import/no-extraneous-dependencies */
/* global globalThis */

import 'raf/polyfill';

// TODO: This is a temporary polyfill necessary for react-router,
// as JSDom does not provide TextEncoder, see:
// https://github.com/remix-run/react-router/issues/12363
if (!globalThis.TextEncoder || !globalThis.TextDecoder) {
const { TextDecoder, TextEncoder } = require('node:util');
globalThis.TextEncoder = TextEncoder;
globalThis.TextDecoder = TextDecoder;
}
74 changes: 38 additions & 36 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 83703e8

Please sign in to comment.