Skip to content

Commit 3be6a04

Browse files
committed
Add test to make sure we're not stupidly flattening styles too early
1 parent 8e8f47c commit 3be6a04

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

__tests__/processPlugins.test.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,59 @@ test('plugins can create components with media queries with object syntax', () =
398398
`)
399399
})
400400

401+
test('media queries can be defined multiple times using objects-in-array syntax', () => {
402+
const [components, utilities] = processPluginsWithValidConfig({
403+
plugins: [
404+
function({ addComponents }) {
405+
addComponents([
406+
{
407+
'.container': {
408+
width: '100%',
409+
},
410+
'@media (min-width: 100px)': {
411+
'.container': {
412+
maxWidth: '100px',
413+
},
414+
},
415+
},
416+
{
417+
'.btn': {
418+
padding: '1rem .5rem',
419+
display: 'block',
420+
},
421+
'@media (min-width: 100px)': {
422+
'.btn': {
423+
display: 'inline-block',
424+
},
425+
},
426+
},
427+
])
428+
},
429+
],
430+
})
431+
432+
expect(utilities.length).toBe(0)
433+
expect(css(components)).toMatchCss(`
434+
.container {
435+
width: 100%
436+
}
437+
@media (min-width: 100px) {
438+
.container {
439+
max-width: 100px
440+
}
441+
}
442+
.btn {
443+
padding: 1rem .5rem;
444+
display: block
445+
}
446+
@media (min-width: 100px) {
447+
.btn {
448+
display: inline-block
449+
}
450+
}
451+
`)
452+
})
453+
401454
test('plugins can create rules with escaped selectors', () => {
402455
const config = {
403456
plugins: [

0 commit comments

Comments
 (0)