summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2019-03-18 00:03:57 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2019-03-18 00:03:57 +0900
commit26845416932ecf0ce035240ce934d2afb77bf550 (patch)
tree41992508c56c9ac05c481f76af524f5a3f14ca31 /test
parentChange default dark theme (diff)
downloadsharkey-26845416932ecf0ce035240ce934d2afb77bf550.tar.gz
sharkey-26845416932ecf0ce035240ce934d2afb77bf550.tar.bz2
sharkey-26845416932ecf0ce035240ce934d2afb77bf550.zip
Custom reaction (#4517)
* Custom reaction * increase limit of reactions/delete * リアクションの場合は OS標準の絵文字を使用 を迂回する * カスタムリアクションを無効にする設定 * fix * disableCustomReaction --> enableEmojiReaction * Avoid MFM rendering * :art: * :art: * Auto accept * custom emoji reaction * Improve usability * Extract emojiRegex * Fix * Clean up * :art: * :art: * toDbReaction で reaction は必須に あとフォールバックは like に * Clean up * Make required * https://github.com/syuilo/misskey/pull/4517/commits/3eb08748feeaab9ee5c5b505c870f97d7edbeb0d#r266241728 * Refactor * Allow null
Diffstat (limited to 'test')
-rw-r--r--test/reaction-lib.ts91
1 files changed, 91 insertions, 0 deletions
diff --git a/test/reaction-lib.ts b/test/reaction-lib.ts
new file mode 100644
index 0000000000..5a128ad7cc
--- /dev/null
+++ b/test/reaction-lib.ts
@@ -0,0 +1,91 @@
+/*
+ * Tests of MFM
+ *
+ * How to run the tests:
+ * > mocha test/reaction-lib.ts --require ts-node/register
+ *
+ * To specify test:
+ * > mocha test/reaction-lib.ts --require ts-node/register -g 'test name'
+ */
+
+import * as assert from 'assert';
+
+import { toDbReaction } from '../src/misc/reaction-lib';
+
+describe('toDbReaction', async () => {
+ it('既存の文字列リアクションはそのまま', async () => {
+ assert.strictEqual(await toDbReaction('like'), 'like');
+ });
+
+ it('Unicodeプリンは寿司化不能とするため文字列化しない', async () => {
+ assert.strictEqual(await toDbReaction('🍮'), '🍮');
+ });
+
+ it('プリン以外の既存のリアクションは文字列化する like', async () => {
+ assert.strictEqual(await toDbReaction('👍'), 'like');
+ });
+
+ it('プリン以外の既存のリアクションは文字列化する love', async () => {
+ assert.strictEqual(await toDbReaction('❤️'), 'love');
+ });
+
+ it('プリン以外の既存のリアクションは文字列化する love 異体字セレクタなし', async () => {
+ assert.strictEqual(await toDbReaction('❤'), 'love');
+ });
+
+ it('プリン以外の既存のリアクションは文字列化する laugh', async () => {
+ assert.strictEqual(await toDbReaction('😆'), 'laugh');
+ });
+
+ it('プリン以外の既存のリアクションは文字列化する hmm', async () => {
+ assert.strictEqual(await toDbReaction('🤔'), 'hmm');
+ });
+
+ it('プリン以外の既存のリアクションは文字列化する surprise', async () => {
+ assert.strictEqual(await toDbReaction('😮'), 'surprise');
+ });
+
+ it('プリン以外の既存のリアクションは文字列化する congrats', async () => {
+ assert.strictEqual(await toDbReaction('🎉'), 'congrats');
+ });
+
+ it('プリン以外の既存のリアクションは文字列化する angry', async () => {
+ assert.strictEqual(await toDbReaction('💢'), 'angry');
+ });
+
+ it('プリン以外の既存のリアクションは文字列化する confused', async () => {
+ assert.strictEqual(await toDbReaction('😥'), 'confused');
+ });
+
+ it('プリン以外の既存のリアクションは文字列化する rip', async () => {
+ assert.strictEqual(await toDbReaction('😇'), 'rip');
+ });
+
+ it('それ以外はUnicodeのまま', async () => {
+ assert.strictEqual(await toDbReaction('🍅'), '🍅');
+ });
+
+ it('異体字セレクタ除去', async () => {
+ assert.strictEqual(await toDbReaction('㊗️'), '㊗');
+ });
+
+ it('異体字セレクタ除去 必要なし', async () => {
+ assert.strictEqual(await toDbReaction('㊗'), '㊗');
+ });
+
+ it('fallback - undefined', async () => {
+ assert.strictEqual(await toDbReaction(undefined), 'like');
+ });
+
+ it('fallback - null', async () => {
+ assert.strictEqual(await toDbReaction(null), 'like');
+ });
+
+ it('fallback - empty', async () => {
+ assert.strictEqual(await toDbReaction(''), 'like');
+ });
+
+ it('fallback - unknown', async () => {
+ assert.strictEqual(await toDbReaction('unknown'), 'like');
+ });
+});