Public Access
test: data router, one render helper, fetchRoutes in every test
This commit is contained in:
1 parent
d0ea9e900d
commit
2a22789435
37 files changed
+454
-425
No files matched your search
@@ -2,6 +2,7 @@
|
||||
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
||||
import {act, cleanup, render} from '@testing-library/react';
|
||||
import {PreferencesProvider, usePreferences} from './PreferencesContext.jsx';
|
||||
import {fetchRoutes, json} from '../test/fetchRoutes.js';
|
||||
|
||||
const i18n = vi.hoisted(() => ({language: 'de'}));
|
||||
vi.mock('react-i18next', async () => {
|
||||
@@ -31,11 +32,10 @@ afterEach(() => {
|
||||
localStorage.clear();
|
||||
});
|
||||
|
||||
const answerMe = (settings) => {
|
||||
globalThis.fetch = vi.fn(async (url, init) => (init?.method === 'PUT'
|
||||
? {ok: true, status: 204}
|
||||
: {ok: true, status: 200, json: async () => ({displayName: 'Lobo', settings})}));
|
||||
};
|
||||
const answerMe = (settings) => fetchRoutes({
|
||||
'GET /api/users/me': json(200, {displayName: 'Lobo', settings}),
|
||||
'PUT /api/users/settings': json(204),
|
||||
});
|
||||
|
||||
describe('PreferencesProvider language', () => {
|
||||
it('takes the language saved in Auth', async () => {
|
||||
|
||||
Reference in new issue
Block a user