8d06a6475e
* chore: 著作権とライセンスについての情報を各ファイルに追加する * 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> * chore: Add SPDX-License-Identifier [skip ci] * add missing SPDX-License-Identifier * remove unused file --------- Co-authored-by: Shun Sakai <sorairolake@protonmail.ch> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: Chocolate Pie <106949016+chocolate-pie@users.noreply.github.com>
55 lines
2.9 KiB
TypeScript
55 lines
2.9 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { checkWordMute } from '@/misc/check-word-mute.js';
|
|
|
|
describe(checkWordMute, () => {
|
|
describe('Slacc boost mode', () => {
|
|
it('should return false if mutedWords is empty', async () => {
|
|
expect(await checkWordMute({ userId: '1', text: 'foo' }, null, [])).toBe(false);
|
|
});
|
|
it('should return true if mutedWords is not empty and text contains muted word', async () => {
|
|
expect(await checkWordMute({ userId: '1', text: 'foo' }, null, [['foo']])).toBe(true);
|
|
});
|
|
it('should return false if mutedWords is not empty and text does not contain muted word', async () => {
|
|
expect(await checkWordMute({ userId: '1', text: 'foo' }, null, [['bar']])).toBe(false);
|
|
});
|
|
it('should return false when the note is written by me even if mutedWords is not empty and text contains muted word', async () => {
|
|
expect(await checkWordMute({ userId: '1', text: 'foo' }, { id: '1' }, [['foo']])).toBe(false);
|
|
});
|
|
it('should return true if mutedWords is not empty and text contains muted word in CW', async () => {
|
|
expect(await checkWordMute({ userId: '1', text: 'foo', cw: 'bar' }, null, [['bar']])).toBe(true);
|
|
});
|
|
it('should return true if mutedWords is not empty and text contains muted word in both CW and text', async () => {
|
|
expect(await checkWordMute({ userId: '1', text: 'foo', cw: 'bar' }, null, [['foo'], ['bar']])).toBe(true);
|
|
});
|
|
it('should return true if mutedWords is not empty and text does not contain muted word in both CW and text', async () => {
|
|
expect(await checkWordMute({ userId: '1', text: 'foo', cw: 'bar' }, null, [['foo'], ['baz']])).toBe(true);
|
|
});
|
|
});
|
|
describe('normal mode', () => {
|
|
it('should return false if text does not contain muted words', async () => {
|
|
expect(await checkWordMute({ userId: '1', text: 'foo' }, null, [['foo', 'bar']])).toBe(false);
|
|
});
|
|
it('should return true if text contains muted words', async () => {
|
|
expect(await checkWordMute({ userId: '1', text: 'foobar' }, null, [['foo', 'bar']])).toBe(true);
|
|
});
|
|
it('should return false when the note is written by me even if text contains muted words', async () => {
|
|
expect(await checkWordMute({ userId: '1', text: 'foo bar' }, { id: '1' }, [['foo', 'bar']])).toBe(false);
|
|
});
|
|
});
|
|
describe('RegExp mode', () => {
|
|
it('should return false if text does not contain muted words', async () => {
|
|
expect(await checkWordMute({ userId: '1', text: 'foo' }, null, ['/bar/'])).toBe(false);
|
|
});
|
|
it('should return true if text contains muted words', async () => {
|
|
expect(await checkWordMute({ userId: '1', text: 'foobar' }, null, ['/bar/'])).toBe(true);
|
|
});
|
|
it('should return false when the note is written by me even if text contains muted words', async () => {
|
|
expect(await checkWordMute({ userId: '1', text: 'foo bar' }, { id: '1' }, ['/bar/'])).toBe(false);
|
|
});
|
|
});
|
|
});
|