remove NestJS instance from MfmService.ts tests
This commit is contained in:
parent
bbdc62992a
commit
c413896a21
1 changed files with 15 additions and 23 deletions
|
|
@ -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>(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 = '<p><span>foo<br>bar<br>baz</span></p>';
|
||||
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 = '<p><span>foo<br>bar<br>baz</span></p>';
|
||||
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<p>Hello, world!</p>\n```';
|
||||
const output = '<p><pre><code><p>Hello, world!</p></code></pre></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('<p>a <ruby>Misskey<rp>(</rp><rt>ミス キー</rt><rp>)</rp> b</ruby> c</p>'), 'a $[ruby $[group Misskey] ミス キー] b c');
|
||||
assert.deepStrictEqual(
|
||||
mfmService.fromHtml('<p>a <ruby>Misskey<rp>(</rp><rt>ミスキー</rt><rp>)</rp>Misskey<rp>(</rp><rt>ミス キー</rt><rp>)</rp>Misskey<rp>(</rp><rt>ミスキー</rt><rp>)</rp></ruby> b</p>'),
|
||||
'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('<ruby> <i>some</i> text <rp>(</rp><rt>ignore me</rt><rp>)</rp> and <rt>more</rt></ruby>'),
|
||||
'$[ruby $[group <i>some</i> text ] ignore me]$[ruby $[group and ] more]'
|
||||
'$[ruby $[group <i>some</i> text ] ignore me]$[ruby $[group and ] more]',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue