2023-07-26 22:31:52 -07:00
|
|
|
/*
|
2024-02-11 18:37:45 -08:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-26 22:31:52 -07:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-02-21 22:16:29 -08:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
|
2023-05-18 02:45:49 -07:00
|
|
|
describe('normalize', () => {
|
2023-02-21 22:16:29 -08:00
|
|
|
test('絵文字リアクションはそのまま', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize('👍'), '👍');
|
|
|
|
assert.strictEqual(await reactionService.normalize('🍅'), '🍅');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('既存のリアクションは絵文字化する pudding', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize('pudding'), '🍮');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('既存のリアクションは絵文字化する like', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize('like'), '👍');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('既存のリアクションは絵文字化する love', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize('love'), '❤');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('既存のリアクションは絵文字化する laugh', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize('laugh'), '😆');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('既存のリアクションは絵文字化する hmm', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize('hmm'), '🤔');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('既存のリアクションは絵文字化する surprise', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize('surprise'), '😮');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('既存のリアクションは絵文字化する congrats', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize('congrats'), '🎉');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('既存のリアクションは絵文字化する angry', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize('angry'), '💢');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('既存のリアクションは絵文字化する confused', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize('confused'), '😥');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('既存のリアクションは絵文字化する rip', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize('rip'), '😇');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('既存のリアクションは絵文字化する star', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize('star'), '⭐');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('異体字セレクタ除去', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize('㊗️'), '㊗');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('異体字セレクタ除去 必要なし', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize('㊗'), '㊗');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('fallback - null', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize(null), '❤');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('fallback - empty', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize(''), '❤');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('fallback - unknown', async () => {
|
2023-05-18 02:45:49 -07:00
|
|
|
assert.strictEqual(await reactionService.normalize('unknown'), '❤');
|
2023-02-21 22:16:29 -08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|