Let users customize the preferred reaction palette
This commit is contained in:
parent
7a5385e00a
commit
f28456c160
38 changed files with 1788 additions and 124 deletions
32
ts/test-both/util/replaceIndex_test.ts
Normal file
32
ts/test-both/util/replaceIndex_test.ts
Normal 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');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue