@@ -2,18 +2,33 @@ const test = require('ava')
22const parser = require ( '../../src/parser' )
33
44test ( 'basic rules are parsed' , async t => {
5- const fixture = 'html {} @media screen { html {} }'
5+ const fixture = 'html {color:red } @media screen { html {} }'
66 const actual = await parser ( fixture )
7- const expected = 2
7+ const expected = [ { declarationsCount : 1 } , { declarationsCount : 0 } ]
88
9- t . is ( actual . rules . length , expected )
9+ t . deepEqual ( actual . rules , expected )
1010} )
1111
1212test ( 'declarations per rule are counted' , async t => {
13- const fixture = ( 'html, body {color:red; font-size : 12px} .foo {color: red;}' )
13+ const fixture = 'html, body {color:red; font-size : 12px} .foo {color: red;}'
14+ const actual = await parser ( fixture )
15+ const expected = [ 2 , 1 ] . map ( num => ( { declarationsCount : num } ) )
16+ t . deepEqual ( actual . rules , expected )
17+ } )
18+
19+ test ( 'heavily nested rules are parsed' , async t => {
20+ const fixture = `
21+ @media screen {
22+ @media print {
23+ @media (min-width: 1px) {
24+ .rule2 {
25+ color: red;
26+ }
27+ }
28+ }
29+ }
30+ `
1431 const actual = await parser ( fixture )
15- const expected = [ 2 , 1 ] . map ( num => {
16- return { declarationsCount : num }
17- } )
32+ const expected = [ { declarationsCount : 1 } ]
1833 t . deepEqual ( actual . rules , expected )
1934} )
0 commit comments