@@ -16,19 +16,13 @@ test('should use the default json saving function if none was supplied', () => {
16
16
17
17
const pluginInstance = containerQuery ( ) ;
18
18
19
- pluginInstance (
20
- ( new Root ( {
21
- input : {
22
- file : 'file/path.css'
23
- }
24
- } ) )
25
- ) ;
19
+ pluginInstance ( new Root ( ) ) ;
26
20
27
21
expect ( saveJSON ) . toHaveBeenCalledTimes ( 1 ) ;
28
22
} ) ;
29
23
30
24
test ( 'missing container declaration' , ( ) => {
31
- const pluginInstance = containerQuery ( { getJson : ( ) => { } } ) ;
25
+ const pluginInstance = containerQuery ( ) ;
32
26
33
27
expect ( ( ) => {
34
28
pluginInstance (
@@ -44,21 +38,112 @@ test('missing container declaration', () => {
44
38
} ) . toThrowError ( new RegExp ( `^A @container query was found, without a preceding @${ DEFINE_CONTAINER_NAME } declaration.$` ) ) ;
45
39
} ) ;
46
40
47
- test ( 'A container should not be able to ' , ( ) => {
48
- const pluginInstance = containerQuery ( { getJson : ( ) => { } } ) ;
41
+ test ( 'should ignore unrecognised at-rules, like @keyframes' , ( done ) => {
42
+ const pluginInstance = containerQuery ( {
43
+ getJSON : ( path , json ) => {
44
+ expect ( json ) . toEqual ( {
45
+ '.container' : {
46
+ selector : '.container' ,
47
+ queries : [
48
+ {
49
+ elements : [
50
+ {
51
+ selector : '.container' ,
52
+ styles : { fontSize : '' , lineHeight : `100${ HEIGHT_UNIT } px` } ,
53
+ } ,
54
+ ] ,
55
+ } ,
56
+ {
57
+ conditions : [ [ [ 'orientation' , ':' , 'landscape' ] ] ] ,
58
+ elements : [
59
+ {
60
+ selector : '.container' ,
61
+ styles : { fontSize : '24px' } ,
62
+ }
63
+ ] ,
64
+ } ,
65
+ ] ,
66
+ } ,
67
+ } ) ;
68
+ done ( ) ;
69
+ } ,
70
+ } ) ;
49
71
50
- expect ( ( ) => {
51
- pluginInstance (
52
- ( new Root ( ) )
53
- . addNode (
54
- new Node ( {
72
+ pluginInstance (
73
+ ( new Root ( ) )
74
+ . addNode (
75
+ new Node ( {
76
+ type : 'rule' ,
77
+ selector : '.container' ,
78
+ } )
79
+ . addNode ( new Node ( {
80
+ type : 'decl' ,
81
+ prop : 'line-height' ,
82
+ value : `100${ HEIGHT_UNIT } px` ,
83
+ } ) )
84
+ . addNode ( new Node ( {
85
+ type : 'decl' ,
86
+ prop : 'font-size' ,
87
+ value : '42px' ,
88
+ } ) )
89
+ . addNode ( new Node ( {
55
90
type : 'atrule' ,
56
- name : 'container' ,
57
- params : '(orientation: landscape)' ,
58
- } )
59
- )
60
- )
61
- } ) . toThrowError ( new RegExp ( `^A @container query was found, without a preceding @${ DEFINE_CONTAINER_NAME } declaration.$` ) ) ;
91
+ name : DEFINE_CONTAINER_NAME ,
92
+ } ) )
93
+ . addNode ( new Node ( {
94
+ type : 'decl' ,
95
+ prop : 'border' ,
96
+ value : 'none' ,
97
+ } ) )
98
+ )
99
+ . addNode (
100
+ new Node ( {
101
+ type : 'atrule' ,
102
+ name : 'keyframes' ,
103
+ params : 'Expand' ,
104
+ } )
105
+ . addNode (
106
+ new Node ( {
107
+ type : 'rule' ,
108
+ selector : '0%' ,
109
+ } )
110
+ . addNode ( new Node ( {
111
+ type : 'decl' ,
112
+ prop : 'opacity' ,
113
+ value : '0%' ,
114
+ } ) )
115
+ )
116
+ . addNode (
117
+ new Node ( {
118
+ type : 'rule' ,
119
+ selector : '100%' ,
120
+ } )
121
+ . addNode ( new Node ( {
122
+ type : 'decl' ,
123
+ prop : 'opacity' ,
124
+ value : '100%' ,
125
+ } ) )
126
+ )
127
+ )
128
+ . addNode (
129
+ new Node ( {
130
+ type : 'atrule' ,
131
+ name : 'container' ,
132
+ params : '(orientation: landscape)' ,
133
+ } )
134
+ . addNode (
135
+ new Node ( {
136
+ type : 'rule' ,
137
+ selector : '.container' ,
138
+ } )
139
+ . addNode ( {
140
+ type : 'decl' ,
141
+ prop : 'font-size' ,
142
+ value : '24px' ,
143
+ } )
144
+ )
145
+ )
146
+ ) ;
62
147
} ) ;
63
148
64
149
test ( 'proper json and css output' , ( ) => {
0 commit comments