@@ -15,7 +15,7 @@ describe('HTML', function() {
15
15
describe ( 'htmlParser' , function ( ) {
16
16
if ( angular . isUndefined ( window . htmlParser ) ) return ;
17
17
18
- var handler , start , text ;
18
+ var handler , start , text , comment ;
19
19
beforeEach ( function ( ) {
20
20
handler = {
21
21
start : function ( tag , attrs , unary ) {
@@ -35,10 +35,42 @@ describe('HTML', function() {
35
35
} ,
36
36
end :function ( tag ) {
37
37
expect ( tag ) . toEqual ( start . tag ) ;
38
+ } ,
39
+ comment :function ( comment_ ) {
40
+ comment = comment_ ;
38
41
}
39
42
} ;
40
43
} ) ;
41
44
45
+ it ( 'should parse comments' , function ( ) {
46
+ htmlParser ( '<!--FOOBAR-->' , handler ) ;
47
+ expect ( comment ) . toEqual ( 'FOOBAR' ) ;
48
+ } ) ;
49
+
50
+ it ( 'should throw an exception for invalid comments' , function ( ) {
51
+ var caught = false ;
52
+ try {
53
+ htmlParser ( '<!-->' , handler ) ;
54
+ }
55
+ catch ( ex ) {
56
+ caught = true ;
57
+ // expected an exception due to a bad parse
58
+ }
59
+ expect ( caught ) . toBe ( true ) ;
60
+ } ) ;
61
+
62
+ it ( 'double-dashes are not allowed in a comment' , function ( ) {
63
+ var caught = false ;
64
+ try {
65
+ htmlParser ( '<!-- -- -->' , handler ) ;
66
+ }
67
+ catch ( ex ) {
68
+ caught = true ;
69
+ // expected an exception due to a bad parse
70
+ }
71
+ expect ( caught ) . toBe ( true ) ;
72
+ } ) ;
73
+
42
74
it ( 'should parse basic format' , function ( ) {
43
75
htmlParser ( '<tag attr="value">text</tag>' , handler ) ;
44
76
expect ( start ) . toEqual ( { tag :'tag' , attrs :{ attr :'value' } , unary :false } ) ;
0 commit comments