Files
cnpmcore/test/core/event/BugVersionFixHandler.test.ts
fengmk2 4427a4fca5 feat: use egg v4 (#747)
BREAKING CHANGE: only support egg >= 4.0.0

the first app on egg v4

https://github.com/eggjs/egg/issues/3644
2025-02-09 15:43:24 +08:00

41 lines
1.5 KiB
TypeScript

import { strict as assert } from 'node:assert';
import { app, mock } from '@eggjs/mock/bootstrap';
import { BUG_VERSIONS } from '../../../app/common/constants';
import { CacheService } from '../../../app/core/service/CacheService';
import { BugVersionFixHandler } from '../../../app/core/event/BugVersionFixHandler';
import { BugVersion } from '../../../app/core/entity/BugVersion';
import { BugVersionService } from '../../../app/core/service/BugVersionService';
describe('test/core/event/BugVersionFixHandler.test.ts', () => {
let cacheService: CacheService;
let bugVersionService: BugVersionService;
const fullnames: string[] = [];
beforeEach(async () => {
cacheService = await app.getEggObject(CacheService);
bugVersionService = await app.getEggObject(BugVersionService);
mock(app.config.cnpmcore, 'allowPublishNonScopePackage', true);
mock(cacheService, 'removeCache', async fullname => {
fullnames.push(fullname);
});
mock(bugVersionService, 'getBugVersion', async () => {
return new BugVersion({
faker: {
'6.6.6': {
version: '5.5.3',
reason: 'Please use https://github.com/MilosPaunovic/community-faker instead',
},
},
});
});
});
it('should clean packages cache', async () => {
const bugVersionFixHandler = await app.getEggObject(BugVersionFixHandler);
await bugVersionFixHandler.handle(BUG_VERSIONS);
assert.deepStrictEqual(fullnames, [
'faker',
]);
});
});