Let users customize the preferred reaction palette

This commit is contained in:
Evan Hahn 2021-09-09 11:29:01 -05:00 committed by GitHub
parent 7a5385e00a
commit f28456c160
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 1788 additions and 124 deletions

View file

@ -0,0 +1,32 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { replaceIndex } from '../../util/replaceIndex';
describe('replaceIndex', () => {
it('returns a new array with an index replaced', () => {
const original = ['a', 'b', 'c', 'd'];
const replaced = replaceIndex(original, 2, 'X');
assert.deepStrictEqual(replaced, ['a', 'b', 'X', 'd']);
});
it("doesn't modify the original array", () => {
const original = ['a', 'b', 'c', 'd'];
replaceIndex(original, 2, 'X');
assert.deepStrictEqual(original, ['a', 'b', 'c', 'd']);
});
it('throws if the index is out of range', () => {
const original = ['a', 'b', 'c'];
[-1, 1.2, 4, Infinity, NaN].forEach(index => {
assert.throws(() => {
replaceIndex(original, index, 'X');
});
});
});
});