One SearchInput to rule them all
This commit is contained in:
parent
c62b5a900e
commit
24b7790829
15 changed files with 266 additions and 232 deletions
41
ts/test-both/util/getClassNamesFor_test.ts
Normal file
41
ts/test-both/util/getClassNamesFor_test.ts
Normal file
|
@ -0,0 +1,41 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { getClassNamesFor } from '../../util/getClassNamesFor';
|
||||
|
||||
describe('getClassNamesFor', () => {
|
||||
it('returns a function', () => {
|
||||
const f = getClassNamesFor('hello-world');
|
||||
assert.isFunction(f);
|
||||
});
|
||||
|
||||
it('returns a function that adds a modifier', () => {
|
||||
const f = getClassNamesFor('module');
|
||||
assert.equal(f('__modifier'), 'module__modifier');
|
||||
});
|
||||
|
||||
it('does not add anything if there is no modifier', () => {
|
||||
const f = getClassNamesFor('module');
|
||||
assert.equal(f(), '');
|
||||
assert.equal(f(undefined && '__modifier'), '');
|
||||
});
|
||||
|
||||
it('but does return the top level module if the modifier is empty string', () => {
|
||||
const f = getClassNamesFor('module1', 'module2');
|
||||
assert.equal(f(''), 'module1 module2');
|
||||
});
|
||||
|
||||
it('adds multiple class names', () => {
|
||||
const f = getClassNamesFor('module1', 'module2', 'module3');
|
||||
assert.equal(
|
||||
f('__modifier'),
|
||||
'module1__modifier module2__modifier module3__modifier'
|
||||
);
|
||||
});
|
||||
|
||||
it('skips parent modules that are undefined', () => {
|
||||
const f = getClassNamesFor('module1', undefined, 'module3');
|
||||
assert.equal(f('__modifier'), 'module1__modifier module3__modifier');
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue