From c413896a211c51a43b7c5ac50db796bc4500d4c6 Mon Sep 17 00:00:00 2001
From: Hazelnoot
Date: Wed, 1 Oct 2025 11:57:34 -0400
Subject: [PATCH] remove NestJS instance from MfmService.ts tests
---
packages/backend/test/unit/MfmService.ts | 38 ++++++++++--------------
1 file changed, 15 insertions(+), 23 deletions(-)
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 = '```\nHello, 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 MisskeyMisskeyMisskey 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 and '),
- '$[ruby $[group some text ] ignore me]$[ruby $[group and ] more]'
+ '$[ruby $[group some text ] ignore me]$[ruby $[group and ] more]',
);
});
});