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:
parent
0fbd31059f
commit
5d68e313c2
8 changed files with 7 additions and 11 deletions
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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',
|
||||||
|
|
|
@ -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',
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -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,
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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",
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue