mizzkey/packages/backend/test/unit/ApMfmService.ts
mattyatea 15005c4266 Merge remote-tracking branch 'misskey-dev/develop' into develop
# Conflicts:
#	.config/docker_example.env
#	.config/docker_example.yml
#	CHANGELOG.md
#	locales/index.d.ts
#	locales/ja-JP.yml
#	packages/backend/package.json
#	packages/backend/src/core/entities/UserEntityService.ts
#	packages/backend/src/server/api/endpoints/i/update.ts
#	packages/frontend/package.json
#	packages/frontend/src/components/MkChannelFollowButton.vue
#	packages/frontend/src/components/MkFollowButton.vue
#	packages/frontend/src/components/MkMediaAudio.vue
#	packages/frontend/src/components/MkMenu.vue
#	packages/frontend/src/components/MkNote.vue
#	packages/frontend/src/components/MkNoteDetailed.vue
#	packages/frontend/src/components/MkPostForm.vue
#	packages/frontend/src/components/MkRadio.vue
#	packages/frontend/src/components/MkSuperMenu.vue
#	packages/frontend/src/components/MkSwitch.vue
#	packages/frontend/src/components/MkVisitorDashboard.vue
#	packages/frontend/src/os.ts
#	packages/frontend/src/pages/about.vue
#	packages/frontend/src/pages/admin/roles.editor.vue
#	packages/frontend/src/pages/admin/roles.vue
#	packages/frontend/src/pages/custom-emojis-manager.vue
#	packages/frontend/src/pages/follow.vue
#	packages/frontend/src/pages/timeline.vue
#	packages/frontend/src/pages/user/home.vue
#	packages/frontend/src/scripts/get-note-menu.ts
#	packages/frontend/src/scripts/keycode.ts
#	packages/frontend/src/ui/_common_/navbar-for-mobile.vue
#	packages/frontend/src/ui/_common_/navbar.vue
#	pnpm-lock.yaml
2024-07-15 20:13:51 +09:00

50 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* SPDX-FileCopyrightText: syuilo and misskey-project , Type4ny-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>(ApMfmService);
});
describe('getNoteHtml', () => {
test('Do not provide _misskey_content for simple text', () => {
const note = {
text: 'テキスト #タグ @mention 🍊 :emoji: https://example.com',
mentionedRemoteUsers: '[]',
};
const { content, noMisskeyContent } = apMfmService.getNoteHtml(note);
assert.equal(noMisskeyContent, true, 'noMisskeyContent');
assert.equal(content, '<p>テキスト <a href="http://misskey.local/tags/タグ" rel="tag">#タグ</a> <a href="http://misskey.local/@mention" class="u-url mention">@mention</a> 🍊 :emoji: <a href="https://example.com">https://example.com</a></p>', 'content');
});
test('Provide _misskey_content for MFM', () => {
const note = {
text: '$[tada foo]',
mentionedRemoteUsers: '[]',
};
const { content, noMisskeyContent } = apMfmService.getNoteHtml(note);
assert.equal(noMisskeyContent, false, 'noMisskeyContent');
assert.equal(content, '<p><i>foo</i></p>', 'content');
});
});
});