Skip to content

Commit 105045a

Browse files
committed
move around mocked modules
1 parent 2466a6e commit 105045a

File tree

5 files changed

+12
-18
lines changed

5 files changed

+12
-18
lines changed

apps/site/tests/loader.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const mockBaseUrl = new URL('mocks/', import.meta.url);
22

33
const mockEntries = [
4-
['github-slugger', 'github-slugger.mjs'],
54
['next-intl', 'next-intl.jsx'],
65
['next-router', 'next-router.mjs'],
76
];

apps/site/tests/mocks/github-slugger.mjs

Lines changed: 0 additions & 9 deletions
This file was deleted.

apps/site/tests/mocks/next-intl.jsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,9 @@ export const useFormatter = () => {
1818
};
1919
};
2020

21-
export const NextIntlClientProvider = ({ children }) => children;
22-
2321
export const createNavigation = () => ({
2422
Link: props => <a {...props} onClick={e => e.preventDefault()} />,
2523
redirect: () => void null,
2624
usePathname: () => '',
2725
useRouter: () => ({ push: () => void null, replace: () => void null }),
2826
});
29-
30-
// eslint-disable-next-line react-hooks/rules-of-hooks
31-
export const getTranslations = () => Promise.resolve(useTranslations());

apps/site/tests/setup.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import '../../../tests/setup.mjs';
22
import { register } from 'node:module';
3+
34
register('./loader.mjs', import.meta.url);

apps/site/util/__tests__/gitHubUtils.test.mjs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
import assert from 'node:assert';
2-
import { describe, it } from 'node:test';
2+
import { describe, it, mock } from 'node:test';
33

4-
import {
4+
mock.module('github-slugger', {
5+
defaultExport: class {
6+
slug() {
7+
return 'mock-slug';
8+
}
9+
},
10+
});
11+
12+
const {
513
getGitHubAvatarUrl,
614
createGitHubSlugger,
715
getGitHubBlobUrl,
816
getGitHubApiDocsUrl,
9-
} from '@/util/gitHubUtils';
17+
} = await import('@/util/gitHubUtils');
1018

1119
describe('gitHubUtils', () => {
1220
it('getGitHubAvatarUrl returns the correct URL', () => {

0 commit comments

Comments
 (0)