add missing shutdown hooks in unit tests

This commit is contained in:
Hazelnoot 2025-09-27 20:08:51 -04:00
parent 4db8d0b9ed
commit b8e3f545c0
10 changed files with 55 additions and 12 deletions

View file

@ -1,5 +1,5 @@
import * as assert from 'assert';
import { Test } from '@nestjs/testing';
import { Test, TestingModule } from '@nestjs/testing';
import { jest } from '@jest/globals';
import { CoreModule } from '@/core/CoreModule.js';
@ -12,21 +12,28 @@ import type { SoftwareSuspension } from '@/models/Meta.js';
import type { MiInstance } from '@/models/Instance.js';
describe('UtilityService', () => {
let app: TestingModule;
let utilityService: UtilityService;
let meta: jest.Mocked<MiMeta>;
beforeAll(async () => {
const app = await Test.createTestingModule({
app = await Test.createTestingModule({
imports: [GlobalModule, CoreModule],
providers: [MetaService],
})
.overrideProvider(MetaService).useValue({ fetch: jest.fn() })
.compile();
app.enableShutdownHooks();
utilityService = app.get<UtilityService>(UtilityService);
meta = app.get<MiMeta>(DI.meta) as jest.Mocked<MiMeta>;
});
afterAll(async () => {
await app.close();
});
describe('punyHost', () => {
test('simple', () => {
assert.equal(utilityService.punyHost('http://www.foo.com'), 'www.foo.com');