/* * SPDX-FileCopyrightText: syuilo and misskey-project * SPDX-License-Identifier: AGPL-3.0-only */ import * as assert from 'assert'; import { Test } from '@nestjs/testing'; import { CoreModule } from '@/core/CoreModule.js'; import { ApMfmService } from '@/core/activitypub/ApMfmService.js'; import { GlobalModule } from '@/GlobalModule.js'; import { MiNote } from '@/models/Note.js'; describe('ApMfmService', () => { let apMfmService: ApMfmService; beforeAll(async () => { const app = await Test.createTestingModule({ imports: [GlobalModule, CoreModule], }).compile(); apMfmService = app.get(ApMfmService); }); describe('getNoteHtml', () => { test('Do not provide _misskey_content for simple text', () => { const note: MiNote = { text: 'テキスト #タグ @mention 🍊 :emoji: https://example.com', mentionedRemoteUsers: '[]', } as FIXME; const { content, noMisskeyContent } = apMfmService.getNoteHtml(note); assert.equal(noMisskeyContent, true, 'noMisskeyContent'); assert.equal(content, '

テキスト @mention 🍊 ​:emoji:​ https://example.com

', 'content'); }); test('Provide _misskey_content for MFM', () => { const note: MiNote = { text: '$[tada foo]', mentionedRemoteUsers: '[]', } as FIXME; const { content, noMisskeyContent } = apMfmService.getNoteHtml(note); assert.equal(noMisskeyContent, false, 'noMisskeyContent'); assert.equal(content, '

foo

', 'content'); }); }); });