3
3
const chai = require ( 'chai' ) ;
4
4
const Parser = require ( '../lib/parser' ) ;
5
5
6
+ const AtWord = require ( '../lib/atword' ) ;
7
+ const Colon = require ( '../lib/colon' ) ;
8
+ const Comma = require ( '../lib/comma' ) ;
9
+ const Comment = require ( '../lib/comment' ) ;
10
+ const Func = require ( '../lib/function' ) ;
11
+ const Numbr = require ( '../lib/number' ) ;
12
+ const Operator = require ( '../lib/operator' ) ;
13
+ const Paren = require ( '../lib/paren' ) ;
14
+ const Str = require ( '../lib/string' ) ;
15
+ const Word = require ( '../lib/word' ) ;
16
+
6
17
let expect = chai . expect ;
7
18
8
19
describe ( 'Parser → API' , ( ) => {
@@ -17,6 +28,34 @@ describe('Parser → API', () => {
17
28
} ) ;
18
29
} ) ;
19
30
31
+ it ( 'should register walkers' , ( ) => {
32
+ let source = '5px solid blue' ,
33
+ ast = new Parser ( source ) . parse ( ) ,
34
+ expected = [ 'number' , 'word' , 'word' ] ,
35
+ types = [
36
+ AtWord ,
37
+ Colon ,
38
+ Comma ,
39
+ Comment ,
40
+ Func ,
41
+ Numbr ,
42
+ Operator ,
43
+ Paren ,
44
+ Str ,
45
+ Word
46
+ ] ;
47
+
48
+ types . forEach ( ( type ) => {
49
+ let name = 'walk' + type . name ;
50
+
51
+ if ( name . lastIndexOf ( 's' ) !== name . length - 1 ) {
52
+ name += 's' ;
53
+ }
54
+
55
+ expect ( ast . first [ name ] ) . to . be . a ( 'function' ) ;
56
+ } ) ;
57
+ } ) ;
58
+
20
59
it ( 'should walk a type string' , ( ) => {
21
60
let source = '5px solid blue' ,
22
61
ast = new Parser ( source ) . parse ( ) ,
0 commit comments