@@ -3,6 +3,13 @@ describe('UNIT: TextNode Parser', function () {
3
3
var TextParser = require ( 'vue/src/text-parser' )
4
4
5
5
describe ( '.parse()' , function ( ) {
6
+
7
+ var tokens , badTokens
8
+
9
+ before ( function ( ) {
10
+ tokens = TextParser . parse ( 'hello {{a}}! {{ bcd }}{{d.e.f}} {{a + (b || c) ? d : e}} {{>test}}{{{ a + "<em>" }}}' )
11
+ badTokens = TextParser . parse ( '{{{a}}{{{{{{{{b}}}}' )
12
+ } )
6
13
7
14
it ( 'should return null if no interpolate tags are present' , function ( ) {
8
15
var result = TextParser . parse ( 'hello no tags' )
@@ -14,11 +21,9 @@ describe('UNIT: TextNode Parser', function () {
14
21
assert . strictEqual ( result . length , 3 )
15
22
assert . strictEqual ( result [ 2 ] , ' {{hello}}' )
16
23
} )
17
-
18
- var tokens = TextParser . parse ( 'hello {{a}}! {{ bcd }}{{d.e.f}} {{a + (b || c) ? d : e}} {{>test}}' )
19
24
20
25
it ( 'should extract correct amount of tokens' , function ( ) {
21
- assert . strictEqual ( tokens . length , 9 )
26
+ assert . strictEqual ( tokens . length , 10 )
22
27
} )
23
28
24
29
it ( 'should extract plain strings' , function ( ) {
@@ -48,6 +53,21 @@ describe('UNIT: TextNode Parser', function () {
48
53
assert . strictEqual ( tokens [ 8 ] . key , '>test' )
49
54
} )
50
55
56
+ it ( 'should extract triple mustache (html instead of text)' , function ( ) {
57
+ assert . strictEqual ( tokens [ 9 ] . key , 'a + "<em>"' )
58
+ assert . ok ( tokens [ 9 ] . html )
59
+ } )
60
+
61
+ it ( 'should deal with bad binding tags' , function ( ) {
62
+ assert . strictEqual ( badTokens . length , 4 )
63
+ assert . strictEqual ( badTokens [ 0 ] . key , 'a' )
64
+ assert . notOk ( badTokens [ 0 ] . html )
65
+ assert . strictEqual ( badTokens [ 1 ] , '{{{{{' )
66
+ assert . strictEqual ( badTokens [ 2 ] . key , 'b' )
67
+ assert . ok ( badTokens [ 2 ] . html )
68
+ assert . strictEqual ( badTokens [ 3 ] , '}' )
69
+ } )
70
+
51
71
} )
52
72
53
73
describe ( '.parseAttr()' , function ( ) {
0 commit comments