tailwindcss/tests/normalize-screens.test.js
Jordan Pittman 66f39a46ab
Add new min and max variants (#9558)
* Rename test variants

* Allow internally negating screens

* Refactor

* Add min/max screen variants

* wip

* Update changelog

* Update tests

* Sort list of variants properly

Technically each test isn’t 100% sorted right in isolation because prettier decisions are basically project-wide. This is close enough though.

* Update tests
2022-10-14 14:25:25 -04:00

64 lines
1.8 KiB
JavaScript

import { normalizeScreens } from '../src/util/normalizeScreens'
it('should normalize an array of string values', () => {
let screens = ['768px', '1200px']
expect(normalizeScreens(screens)).toEqual([
{ name: '768px', not: false, values: [{ min: '768px', max: undefined }] },
{ name: '1200px', not: false, values: [{ min: '1200px', max: undefined }] },
])
})
it('should normalize an object with string values', () => {
let screens = {
a: '768px',
b: '1200px',
}
expect(normalizeScreens(screens)).toEqual([
{ name: 'a', not: false, values: [{ min: '768px', max: undefined }] },
{ name: 'b', not: false, values: [{ min: '1200px', max: undefined }] },
])
})
it('should normalize an object with object values', () => {
let screens = {
a: { min: '768px' },
b: { max: '1200px' },
}
expect(normalizeScreens(screens)).toEqual([
{ name: 'a', not: false, values: [{ min: '768px', max: undefined }] },
{ name: 'b', not: false, values: [{ min: undefined, max: '1200px' }] },
])
})
it('should normalize an object with multiple object values', () => {
let screens = {
a: [{ min: '768px' }, { max: '1200px' }],
}
expect(normalizeScreens(screens)).toEqual([
{
name: 'a',
not: false,
values: [
{ max: undefined, min: '768px', raw: undefined },
{ max: '1200px', min: undefined, raw: undefined },
],
},
])
})
it('should normalize an object with object values (min-width normalized to width)', () => {
let screens = {
a: { 'min-width': '768px' },
b: { max: '1200px' },
}
expect(normalizeScreens(screens)).toEqual([
{ name: 'a', not: false, values: [{ min: '768px', max: undefined }] },
{ name: 'b', not: false, values: [{ min: undefined, max: '1200px' }] },
])
})