hedgedoc/frontend/src/utils/concat-css-classes.spec.ts
Tilman Vatteroth 4eb341308a feat: add concat-css-classes helper method
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
2023-05-21 22:31:52 +02:00

32 lines
935 B
TypeScript

/*
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { concatCssClasses } from './concat-css-classes'
describe('concat css classes', () => {
it('works with a map', () => {
expect(concatCssClasses({ a: true, b: false, c: true })).toBe('a c')
})
it('works with a string array ', () => {
expect(concatCssClasses('a', 'b', 'c')).toBe('a b c')
})
it('works with a string array and map', () => {
expect(concatCssClasses('a', 'b', 'c', { d: true, e: false, f: true })).toBe('a b c d f')
})
it("doesn't include undefined and null", () => {
expect(concatCssClasses(undefined, null)).toBe('')
})
it("doesn't include duplicates", () => {
expect(concatCssClasses('a', 'a', { a: true })).toBe('a')
})
it("doesn't include empty class names", () => {
expect(concatCssClasses('a', '', { '': true })).toBe('a')
})
})