Skip to content

Commit

Permalink
define test (#584)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann authored Apr 20, 2023
1 parent b65fe58 commit 45b5e51
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions src/formats/cssWrapMediaQuery.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import {cssWrapMediaQuery} from './cssWrapMediaQuery'
import {getMockFormatterArguments} from '~/src/test-utilities'
import {format} from 'prettier'

describe('Format: tokens nested in media query', () => {
it('Wraps in screen if no media query defined', () => {
const input = getMockFormatterArguments()
const expectedOutput = format(
` @media screen {
:root {
--red: transformedValue;
}
}`,
{parser: 'css', printWidth: 500},
)
expect(cssWrapMediaQuery(input)).toStrictEqual(expectedOutput)
})

it('Wraps in screen if no matching media query is found', () => {
const input = getMockFormatterArguments({
options: {
mediaQuery: {
'size-fine.css': '(pointer: fine)',
},
},
file: {
destination: 'size-coarse.css',
options: {
showFileHeader: false,
},
},
})
const expectedOutput = format(
` @media screen {
:root {
--red: transformedValue;
}
}`,
{parser: 'css', printWidth: 500},
)
expect(cssWrapMediaQuery(input)).toStrictEqual(expectedOutput)
})

it('Wraps in defined media query if files match', () => {
const input = getMockFormatterArguments({
options: {
mediaQuery: {
'size-fine.css': '(pointer: fine)',
},
},
file: {
destination: 'size-fine.css',
options: {
showFileHeader: false,
},
},
})
const expectedOutput = format(
` @media (pointer: fine) {
:root {
--red: transformedValue;
}
}`,
{parser: 'css', printWidth: 500},
)
expect(cssWrapMediaQuery(input)).toStrictEqual(expectedOutput)
})
})

0 comments on commit 45b5e51

Please sign in to comment.