1
0
forked from mirror/misskey
mi.moris.day/packages/backend/test/unit/ReactionService.ts
Shun Sakai c2370a1be6
chore: 著作権とライセンスについての情報を各ファイルに追加する (#11348)
* chore: Add the SPDX information to each file

Add copyright and licensing information as defined in version 3.0 of
the REUSE Specification.

* tweak format

---------

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
2023-07-27 14:31:52 +09:00

94 lines
3.2 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 other misskey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
import * as assert from 'assert';
import { Test } from '@nestjs/testing';
import { CoreModule } from '@/core/CoreModule.js';
import { ReactionService } from '@/core/ReactionService.js';
import { GlobalModule } from '@/GlobalModule.js';
describe('ReactionService', () => {
let reactionService: ReactionService;
beforeAll(async () => {
const app = await Test.createTestingModule({
imports: [GlobalModule, CoreModule],
}).compile();
reactionService = app.get<ReactionService>(ReactionService);
});
describe('normalize', () => {
test('絵文字リアクションはそのまま', async () => {
assert.strictEqual(await reactionService.normalize('👍'), '👍');
assert.strictEqual(await reactionService.normalize('🍅'), '🍅');
});
test(' pudding', async () => {
assert.strictEqual(await reactionService.normalize('pudding'), '🍮');
});
test(' like', async () => {
assert.strictEqual(await reactionService.normalize('like'), '👍');
});
test(' love', async () => {
assert.strictEqual(await reactionService.normalize('love'), '');
});
test(' laugh', async () => {
assert.strictEqual(await reactionService.normalize('laugh'), '😆');
});
test(' hmm', async () => {
assert.strictEqual(await reactionService.normalize('hmm'), '🤔');
});
test(' surprise', async () => {
assert.strictEqual(await reactionService.normalize('surprise'), '😮');
});
test(' congrats', async () => {
assert.strictEqual(await reactionService.normalize('congrats'), '🎉');
});
test(' angry', async () => {
assert.strictEqual(await reactionService.normalize('angry'), '💢');
});
test(' confused', async () => {
assert.strictEqual(await reactionService.normalize('confused'), '😥');
});
test(' rip', async () => {
assert.strictEqual(await reactionService.normalize('rip'), '😇');
});
test(' star', async () => {
assert.strictEqual(await reactionService.normalize('star'), '');
});
test('', async () => {
assert.strictEqual(await reactionService.normalize(''), '');
});
test(' ', async () => {
assert.strictEqual(await reactionService.normalize(''), '');
});
test('fallback - null', async () => {
assert.strictEqual(await reactionService.normalize(null), '');
});
test('fallback - empty', async () => {
assert.strictEqual(await reactionService.normalize(''), '');
});
test('fallback - unknown', async () => {
assert.strictEqual(await reactionService.normalize('unknown'), '');
});
});
});