@@ -22,9 +22,9 @@ describe('UNIT: Directive', function () {
22
22
it ( 'should return array with the string if it\'s a single clause' , function ( ) {
23
23
var e ,
24
24
test1 = 'fsef' ,
25
- test2 = 'ffsef + "fse, fsef"' ,
25
+ test2 = 'ffsef + "fse& fsef"' ,
26
26
test3 = 'fsef + \'fesfsfe\'' ,
27
- test4 = '\"fsefsf, fsef, fsef\"'
27
+ test4 = '\"fsefsf& fsef& fsef\"'
28
28
29
29
e = Directive . split ( test1 )
30
30
assert . strictEqual ( e . length , 1 )
@@ -45,28 +45,28 @@ describe('UNIT: Directive', function () {
45
45
46
46
it ( 'should return split multiple clauses correctly' , function ( ) {
47
47
var e ,
48
- test1 = [ 'fsef' , 'fsf:fsefsef' ] ,
49
- test2 = [ 'asf-fsef:fsf' , '"efs, sefsf"' ] ,
50
- test3 = [ '\'fsef, sef\'' , 'fse:fsf' ] ,
51
- test4 = [ '\"fsef, fsef\"' , 'sefsef\'fesfsf' ]
48
+ test1 = [ 'fsef && ggg ' , 'fsf:fsefsef' ] ,
49
+ test2 = [ 'asf-fsef:fsf' , '"efs& sefsf"' ] ,
50
+ test3 = [ '\'fsef& sef\'' , 'fse:fsf' ] ,
51
+ test4 = [ '\"fsef& fsef\"' , 'sefsef\'fesfsf' ]
52
52
53
- e = Directive . split ( test1 . join ( ', ' ) )
54
- assert . strictEqual ( e . length , 2 )
53
+ e = Directive . split ( test1 . join ( '& ' ) )
54
+ assert . strictEqual ( e . length , 2 , 'expression with &&' )
55
55
assert . strictEqual ( e [ 0 ] , test1 [ 0 ] )
56
56
assert . strictEqual ( e [ 1 ] , test1 [ 1 ] )
57
57
58
- e = Directive . split ( test2 . join ( ', ' ) )
59
- assert . strictEqual ( e . length , 2 )
58
+ e = Directive . split ( test2 . join ( '& ' ) )
59
+ assert . strictEqual ( e . length , 2 , 'expression with double quotes' )
60
60
assert . strictEqual ( e [ 0 ] , test2 [ 0 ] )
61
61
assert . strictEqual ( e [ 1 ] , test2 [ 1 ] )
62
62
63
- e = Directive . split ( test3 . join ( ', ' ) )
64
- assert . strictEqual ( e . length , 2 )
63
+ e = Directive . split ( test3 . join ( '& ' ) )
64
+ assert . strictEqual ( e . length , 2 , 'expression with single quotes' )
65
65
assert . strictEqual ( e [ 0 ] , test3 [ 0 ] )
66
66
assert . strictEqual ( e [ 1 ] , test3 [ 1 ] )
67
67
68
- e = Directive . split ( test4 . join ( ', ' ) )
69
- assert . strictEqual ( e . length , 2 )
68
+ e = Directive . split ( test4 . join ( '& ' ) )
69
+ assert . strictEqual ( e . length , 2 , 'expression with escaped quotes' )
70
70
assert . strictEqual ( e [ 0 ] , test4 [ 0 ] )
71
71
assert . strictEqual ( e [ 1 ] , test4 [ 1 ] )
72
72
} )
@@ -139,6 +139,15 @@ describe('UNIT: Directive', function () {
139
139
assert . strictEqual ( d . expression , exp . trim ( ) )
140
140
} )
141
141
142
+ it ( 'should extract correct key' , function ( ) {
143
+ var d = Directive . parse ( 'sd-text' , '"fsefse | fsefsef" && bc' , compiler ) ,
144
+ e = Directive . parse ( 'sd-text' , '"fsefsf & fsefs" | test' , compiler ) ,
145
+ f = Directive . parse ( 'sd-text' , '"fsef:fsefsf" || ff' , compiler )
146
+ assert . strictEqual ( d . key , '"fsefse | fsefsef" && bc' , 'pipe inside quotes and &&' )
147
+ assert . strictEqual ( e . key , '"fsefsf & fsefs"' , '& inside quotes with filter' )
148
+ assert . strictEqual ( f . key , '"fsef:fsefsf" || ff' , ': inside quotes and ||' )
149
+ } )
150
+
142
151
it ( 'should extract correct argument' , function ( ) {
143
152
var d = Directive . parse ( 'sd-text' , 'todo:todos' , compiler ) ,
144
153
e = Directive . parse ( 'sd-text' , 'todo:todos + abc' , compiler ) ,
@@ -190,15 +199,15 @@ describe('UNIT: Directive', function () {
190
199
} )
191
200
192
201
it ( 'should extract correct filters (single filter)' , function ( ) {
193
- var d = Directive . parse ( 'sd-text' , 'abc | uppercase' , compiler ) ,
202
+ var d = Directive . parse ( 'sd-text' , 'abc || a + "b|c" | uppercase' , compiler ) ,
194
203
f = d . filters [ 0 ]
195
204
assert . strictEqual ( f . name , 'uppercase' )
196
205
assert . strictEqual ( f . args , null )
197
206
assert . strictEqual ( f . apply ( 'test' ) , 'TEST' )
198
207
} )
199
208
200
209
it ( 'should extract correct filters (single filter with args)' , function ( ) {
201
- var d = Directive . parse ( 'sd-text' , 'abc | pluralize item \'arg with spaces\'' , compiler ) ,
210
+ var d = Directive . parse ( 'sd-text' , 'abc + \'b | c | d\' | pluralize item \'arg with spaces\'' , compiler ) ,
202
211
f = d . filters [ 0 ]
203
212
assert . strictEqual ( f . name , 'pluralize' , 'name' )
204
213
assert . strictEqual ( f . args . length , 2 , 'args length' )
0 commit comments