From 5d68e313c27afb164e0e7208d0dbbee6f86c3e00 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Fri, 7 Apr 2023 00:58:13 +0800 Subject: [PATCH] refactor: fix tests --- packages/core/src/libraries/hook.test.ts | 4 ++-- packages/core/src/middleware/koa-audit-log.test.ts | 2 +- packages/core/src/routes/application.test.ts | 2 +- packages/core/src/routes/resource.test.ts | 2 +- packages/core/src/test-utils/nanoid.ts | 2 +- packages/ui/jest.config.ts | 2 +- packages/ui/package.json | 1 - pnpm-lock.yaml | 3 --- 8 files changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/core/src/libraries/hook.test.ts b/packages/core/src/libraries/hook.test.ts index a1b23592c..a516ae02b 100644 --- a/packages/core/src/libraries/hook.test.ts +++ b/packages/core/src/libraries/hook.test.ts @@ -6,10 +6,10 @@ import { got } from 'got'; import type { Interaction } from './hook.js'; const { jest } = import.meta; -const { mockEsmDefault, mockEsmWithActual } = createMockUtils(jest); +const { mockEsmWithActual } = createMockUtils(jest); const nanoIdMock = 'mockId'; -await mockEsmWithActual('@logto/core-kit', () => ({ +await mockEsmWithActual('@logto/shared', () => ({ // eslint-disable-next-line unicorn/consistent-function-scoping buildIdGenerator: () => () => nanoIdMock, generateStandardId: () => nanoIdMock, diff --git a/packages/core/src/middleware/koa-audit-log.test.ts b/packages/core/src/middleware/koa-audit-log.test.ts index ec2142dbf..919ee049a 100644 --- a/packages/core/src/middleware/koa-audit-log.test.ts +++ b/packages/core/src/middleware/koa-audit-log.test.ts @@ -10,7 +10,7 @@ const { jest } = import.meta; const { mockEsmWithActual } = createMockUtils(jest); const nanoIdMock = 'mockId'; -await mockEsmWithActual('@logto/core-kit', () => ({ +await mockEsmWithActual('@logto/shared', () => ({ // eslint-disable-next-line unicorn/consistent-function-scoping buildIdGenerator: () => () => nanoIdMock, generateStandardId: () => nanoIdMock, diff --git a/packages/core/src/routes/application.test.ts b/packages/core/src/routes/application.test.ts index 32bc9b093..1aaf6d2b2 100644 --- a/packages/core/src/routes/application.test.ts +++ b/packages/core/src/routes/application.test.ts @@ -11,7 +11,7 @@ const { mockEsmWithActual } = createMockUtils(jest); const findApplicationById = jest.fn(async () => mockApplication); const deleteApplicationById = jest.fn(); -await mockEsmWithActual('@logto/core-kit', () => ({ +await mockEsmWithActual('@logto/shared', () => ({ // eslint-disable-next-line unicorn/consistent-function-scoping buildIdGenerator: () => () => 'randomId', generateStandardId: () => 'randomId', diff --git a/packages/core/src/routes/resource.test.ts b/packages/core/src/routes/resource.test.ts index a6ef70388..5b7ce0de2 100644 --- a/packages/core/src/routes/resource.test.ts +++ b/packages/core/src/routes/resource.test.ts @@ -47,7 +47,7 @@ const libraries = { }, }; -mockEsm('@logto/core-kit', () => ({ +mockEsm('@logto/shared', () => ({ // eslint-disable-next-line unicorn/consistent-function-scoping buildIdGenerator: () => () => 'randomId', })); diff --git a/packages/core/src/test-utils/nanoid.ts b/packages/core/src/test-utils/nanoid.ts index 4e719e802..411c6b37c 100644 --- a/packages/core/src/test-utils/nanoid.ts +++ b/packages/core/src/test-utils/nanoid.ts @@ -4,6 +4,6 @@ const { mockEsmWithActual } = createMockUtils(import.meta.jest); export const mockId = 'mockId'; export const mockStandardId = async () => - mockEsmWithActual('@logto/core-kit', () => ({ + mockEsmWithActual('@logto/shared', () => ({ generateStandardId: () => mockId, })); diff --git a/packages/ui/jest.config.ts b/packages/ui/jest.config.ts index a2dbc3967..b61238ad1 100644 --- a/packages/ui/jest.config.ts +++ b/packages/ui/jest.config.ts @@ -11,7 +11,7 @@ const config: Config.InitialOptions = { }, moduleNameMapper: { '^@logto/app-insights/(.*)$': '/node_modules/@logto/app-insights/lib/$1', - '^@logto/shared/(.*)$': '/node_modules/@logto/shared/lib/$1', + '^@logto/shared/(.*)$': '/../shared/lib/$1', }, }), // Will update common config soon diff --git a/packages/ui/package.json b/packages/ui/package.json index 935cd1b56..c361077c0 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -27,7 +27,6 @@ "@logto/phrases": "workspace:^", "@logto/phrases-ui": "workspace:^", "@logto/schemas": "workspace:^", - "@logto/shared": "workspace:^", "@parcel/compressor-brotli": "2.8.3", "@parcel/compressor-gzip": "2.8.3", "@parcel/core": "2.8.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 28e34839c..9d2fbeaba 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3802,9 +3802,6 @@ importers: '@logto/schemas': specifier: workspace:^ version: link:../schemas - '@logto/shared': - specifier: workspace:^ - version: link:../shared '@parcel/compressor-brotli': specifier: 2.8.3 version: 2.8.3(@parcel/core@2.8.3)