diff --git a/packages/backend/test/unit/MfmService.ts b/packages/backend/test/unit/MfmService.ts index f9a7ea100d..8366f8ed59 100644 --- a/packages/backend/test/unit/MfmService.ts +++ b/packages/backend/test/unit/MfmService.ts @@ -5,26 +5,18 @@ import * as assert from 'assert'; import * as mfm from 'mfm-js'; -import { Test, TestingModule } from '@nestjs/testing'; - -import { CoreModule } from '@/core/CoreModule.js'; +import type { Config } from '@/config.js'; import { MfmService } from '@/core/MfmService.js'; -import { GlobalModule } from '@/GlobalModule.js'; describe('MfmService', () => { - let app: TestingModule; + let config: Config; let mfmService: MfmService; - beforeAll(async () => { - app = await Test.createTestingModule({ - imports: [GlobalModule, CoreModule], - }).compile(); - app.enableShutdownHooks(); - mfmService = app.get(MfmService); - }); - - afterAll(async () => { - await app.close(); + beforeEach(() => { + config = { + url: 'https://example.com', + } as unknown as Config; + mfmService = new MfmService(config); }); describe('toHtml', () => { @@ -78,22 +70,22 @@ describe('MfmService', () => { }); describe('toMastoApiHtml', () => { - test('br', async () => { + test('br', () => { const input = 'foo\nbar\nbaz'; const output = '

foo
bar
baz

'; - assert.equal(await mfmService.toMastoApiHtml(mfm.parse(input)), output); + assert.equal(mfmService.toMastoApiHtml(mfm.parse(input)), output); }); - test('br alt', async () => { + test('br alt', () => { const input = 'foo\r\nbar\rbaz'; const output = '

foo
bar
baz

'; - assert.equal(await mfmService.toMastoApiHtml(mfm.parse(input)), output); + assert.equal(mfmService.toMastoApiHtml(mfm.parse(input)), output); }); - test('escape', async () => { + test('escape', () => { const input = '```\n

Hello, world!

\n```'; const output = '

<p>Hello, world!</p>

'; - assert.equal(await mfmService.toMastoApiHtml(mfm.parse(input)), output); + assert.equal(mfmService.toMastoApiHtml(mfm.parse(input)), output); }); test('ruby', async () => { @@ -174,7 +166,7 @@ describe('MfmService', () => { assert.deepStrictEqual(mfmService.fromHtml('

a Misskey(ミス キー) b c

'), 'a $[ruby $[group Misskey] ミス キー] b c'); assert.deepStrictEqual( mfmService.fromHtml('

a Misskey(ミスキー)Misskey(ミス キー)Misskey(ミスキー) b

'), - 'a $[ruby Misskey ミスキー]$[ruby $[group Misskey] ミス キー]$[ruby Misskey ミスキー] b' + 'a $[ruby Misskey ミスキー]$[ruby $[group Misskey] ミス キー]$[ruby Misskey ミスキー] b', ); }); @@ -193,7 +185,7 @@ describe('MfmService', () => { test('ruby', () => { assert.deepStrictEqual( mfmService.fromHtml(' some text (ignore me) and more'), - '$[ruby $[group some text ] ignore me]$[ruby $[group and ] more]' + '$[ruby $[group some text ] ignore me]$[ruby $[group and ] more]', ); }); });