0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

refactor: fix tests

This commit is contained in:
Gao Sun 2023-04-07 00:58:13 +08:00
parent 0fbd31059f
commit 5d68e313c2
No known key found for this signature in database
GPG key ID: 13EBE123E4773688
8 changed files with 7 additions and 11 deletions

View file

@ -6,10 +6,10 @@ import { got } from 'got';
import type { Interaction } from './hook.js'; import type { Interaction } from './hook.js';
const { jest } = import.meta; const { jest } = import.meta;
const { mockEsmDefault, mockEsmWithActual } = createMockUtils(jest); const { mockEsmWithActual } = createMockUtils(jest);
const nanoIdMock = 'mockId'; const nanoIdMock = 'mockId';
await mockEsmWithActual('@logto/core-kit', () => ({ await mockEsmWithActual('@logto/shared', () => ({
// eslint-disable-next-line unicorn/consistent-function-scoping // eslint-disable-next-line unicorn/consistent-function-scoping
buildIdGenerator: () => () => nanoIdMock, buildIdGenerator: () => () => nanoIdMock,
generateStandardId: () => nanoIdMock, generateStandardId: () => nanoIdMock,

View file

@ -10,7 +10,7 @@ const { jest } = import.meta;
const { mockEsmWithActual } = createMockUtils(jest); const { mockEsmWithActual } = createMockUtils(jest);
const nanoIdMock = 'mockId'; const nanoIdMock = 'mockId';
await mockEsmWithActual('@logto/core-kit', () => ({ await mockEsmWithActual('@logto/shared', () => ({
// eslint-disable-next-line unicorn/consistent-function-scoping // eslint-disable-next-line unicorn/consistent-function-scoping
buildIdGenerator: () => () => nanoIdMock, buildIdGenerator: () => () => nanoIdMock,
generateStandardId: () => nanoIdMock, generateStandardId: () => nanoIdMock,

View file

@ -11,7 +11,7 @@ const { mockEsmWithActual } = createMockUtils(jest);
const findApplicationById = jest.fn(async () => mockApplication); const findApplicationById = jest.fn(async () => mockApplication);
const deleteApplicationById = jest.fn(); const deleteApplicationById = jest.fn();
await mockEsmWithActual('@logto/core-kit', () => ({ await mockEsmWithActual('@logto/shared', () => ({
// eslint-disable-next-line unicorn/consistent-function-scoping // eslint-disable-next-line unicorn/consistent-function-scoping
buildIdGenerator: () => () => 'randomId', buildIdGenerator: () => () => 'randomId',
generateStandardId: () => 'randomId', generateStandardId: () => 'randomId',

View file

@ -47,7 +47,7 @@ const libraries = {
}, },
}; };
mockEsm('@logto/core-kit', () => ({ mockEsm('@logto/shared', () => ({
// eslint-disable-next-line unicorn/consistent-function-scoping // eslint-disable-next-line unicorn/consistent-function-scoping
buildIdGenerator: () => () => 'randomId', buildIdGenerator: () => () => 'randomId',
})); }));

View file

@ -4,6 +4,6 @@ const { mockEsmWithActual } = createMockUtils(import.meta.jest);
export const mockId = 'mockId'; export const mockId = 'mockId';
export const mockStandardId = async () => export const mockStandardId = async () =>
mockEsmWithActual('@logto/core-kit', () => ({ mockEsmWithActual('@logto/shared', () => ({
generateStandardId: () => mockId, generateStandardId: () => mockId,
})); }));

View file

@ -11,7 +11,7 @@ const config: Config.InitialOptions = {
}, },
moduleNameMapper: { moduleNameMapper: {
'^@logto/app-insights/(.*)$': '<rootDir>/node_modules/@logto/app-insights/lib/$1', '^@logto/app-insights/(.*)$': '<rootDir>/node_modules/@logto/app-insights/lib/$1',
'^@logto/shared/(.*)$': '<rootDir>/node_modules/@logto/shared/lib/$1', '^@logto/shared/(.*)$': '<rootDir>/../shared/lib/$1',
}, },
}), }),
// Will update common config soon // Will update common config soon

View file

@ -27,7 +27,6 @@
"@logto/phrases": "workspace:^", "@logto/phrases": "workspace:^",
"@logto/phrases-ui": "workspace:^", "@logto/phrases-ui": "workspace:^",
"@logto/schemas": "workspace:^", "@logto/schemas": "workspace:^",
"@logto/shared": "workspace:^",
"@parcel/compressor-brotli": "2.8.3", "@parcel/compressor-brotli": "2.8.3",
"@parcel/compressor-gzip": "2.8.3", "@parcel/compressor-gzip": "2.8.3",
"@parcel/core": "2.8.3", "@parcel/core": "2.8.3",

View file

@ -3802,9 +3802,6 @@ importers:
'@logto/schemas': '@logto/schemas':
specifier: workspace:^ specifier: workspace:^
version: link:../schemas version: link:../schemas
'@logto/shared':
specifier: workspace:^
version: link:../shared
'@parcel/compressor-brotli': '@parcel/compressor-brotli':
specifier: 2.8.3 specifier: 2.8.3
version: 2.8.3(@parcel/core@2.8.3) version: 2.8.3(@parcel/core@2.8.3)