Skip to content

Commit

Permalink
test: add *ClassName tests (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomaash committed Aug 2, 2019
1 parent f4cdcc6 commit 92dc6ef
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/add-class-name.test.ts
@@ -0,0 +1,22 @@
import { expect } from 'chai'

import { addClassName } from '../src'

describe('addClassName', function(): void {
const inputs: { input: string; classes: string; expected: string }[] = [
{ input: 'a b c', classes: 'a c', expected: 'a b c' },
{ input: 'a b c', classes: 'd', expected: 'a b c d' },
{ input: 'c', classes: 'a b', expected: 'c a b' },
{ input: 'class-1 class-2', classes: 'class-3', expected: 'class-1 class-2 class-3' },
]

inputs.forEach(({ input, classes, expected }): void => {
it(`${input} + ${classes} = ${expected}`, function(): void {
const elem = { className: input }

addClassName(elem as any, classes)

expect(elem.className).to.equal(expected)
})
})
})
22 changes: 22 additions & 0 deletions test/remove-class-name.test.ts
@@ -0,0 +1,22 @@
import { expect } from 'chai'

import { removeClassName } from '../src'

describe('removeClassName', function(): void {
const inputs: { input: string; classes: string; expected: string }[] = [
{ input: 'a b c', classes: 'a c', expected: 'b' },
{ input: 'a b c', classes: 'b', expected: 'a c' },
{ input: 'a b c', classes: 'd', expected: 'a b c' },
{ input: 'class-1 class-2', classes: 'class-2', expected: 'class-1' },
]

inputs.forEach(({ input, classes, expected }): void => {
it(`${input} - ${classes} = ${expected}`, function(): void {
const elem = { className: input }

removeClassName(elem as any, classes)

expect(elem.className).to.equal(expected)
})
})
})

0 comments on commit 92dc6ef

Please sign in to comment.