Skip to content

Commit

Permalink
Add class list tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thecrypticace committed Feb 7, 2022
1 parent 46c860a commit cb840bb
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/getClassList.test.js
Expand Up @@ -26,3 +26,36 @@ it('should generate every possible class, without variants', () => {

expect(classes).not.toContain('-m-DEFAULT')
})

it('should generate every possible class while handling negatives and prefixes', () => {
let config = { prefix: 'tw-' }
let context = createContext(resolveConfig(config))
let classes = context.getClassList()
expect(classes).toBeInstanceOf(Array)

// Verify we have a `container` for the 'components' section.
expect(classes).toContain('tw-container')

// Verify we handle the DEFAULT case correctly
expect(classes).toContain('tw-border')

// Verify we handle negative values correctly
expect(classes).toContain('-tw-inset-1/4')
expect(classes).toContain('-tw-m-0')
expect(classes).not.toContain('-tw-uppercase')
expect(classes).not.toContain('-tw-opacity-50')

// These utilities do work but there's no reason to generate
// them alongside the `-{prefix}-{utility}` versions
expect(classes).not.toContain('tw--inset-1/4')
expect(classes).not.toContain('tw--m-0')

config = {
prefix: 'tw-',
theme: { extend: { margin: { DEFAULT: '5px' } } },
}
context = createContext(resolveConfig(config))
classes = context.getClassList()

expect(classes).not.toContain('-tw-m-DEFAULT')
})

0 comments on commit cb840bb

Please sign in to comment.