signal-desktop/ts/test-both/reactions/isValidReactionEmoji_test.ts

33 lines
1.1 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.

// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { isValidReactionEmoji } from '../../reactions/isValidReactionEmoji';
describe('isValidReactionEmoji', () => {
it('returns false for non-strings', () => {
assert.isFalse(isValidReactionEmoji(undefined));
assert.isFalse(isValidReactionEmoji(null));
assert.isFalse(isValidReactionEmoji(1));
});
it("returns false for strings that aren't a single emoji", () => {
assert.isFalse(isValidReactionEmoji(''));
assert.isFalse(isValidReactionEmoji('a'));
assert.isFalse(isValidReactionEmoji('abc'));
assert.isFalse(isValidReactionEmoji('💩💩'));
assert.isFalse(isValidReactionEmoji('🇸'));
assert.isFalse(isValidReactionEmoji(''));
});
it('returns true for strings that are exactly 1 emoji', () => {
assert.isTrue(isValidReactionEmoji('🇺🇸'));
assert.isTrue(isValidReactionEmoji('👍'));
assert.isTrue(isValidReactionEmoji('👍🏾'));
assert.isTrue(isValidReactionEmoji('👩‍❤️‍👩'));
});
});