@@ -29,7 +29,7 @@ describe('@onComplete', function() {
2929 } ;
3030 } ;
3131
32- it ( 'should add a @onComplete string to the page' , function ( ) {
32+ it ( 'should add @onComplete string to the page' , function ( ) {
3333 var lines = [ '### Page One' , 'page description' , 'more page description' , '@onComplete("next page")' ] ;
3434 var next = page ( result ( ) , lines , index ( ) ) ;
3535 var nextPage = next . chapters [ 0 ] . pages [ 0 ] ;
@@ -38,12 +38,36 @@ describe('@onComplete', function() {
3838 description : 'page description\nmore page description' ,
3939 onComplete : 'next page'
4040 } ) ;
41+ } ) ;
42+
43+ it ( 'should handle multi-line codeblocks' , function ( ) {
44+ var lines = [ '### Page One' , 'page description' , 'more page description' ,
45+ '@onComplete("next page' , '```' , 'var a = 42;' , '```' , '")' ] ;
46+ var next = page ( result ( ) , lines , index ( ) ) ;
47+ var nextPage = next . chapters [ 0 ] . pages [ 0 ] ;
48+ expect ( nextPage ) . to . deep . equal ( {
49+ title : 'Page One' ,
50+ description : 'page description\nmore page description' ,
51+ onComplete : 'next page\n```\nvar a = 42;\n```'
52+ } ) ;
53+ } ) ;
4154
42- it ( 'shouldn\'t add a @onComplete string to a task' , function ( ) {
43- var lines = [ '+ Task One' , 'with more on the next' , 'line' , '@onComplete("next page")' ] ;
44- var next = task ( resultTask ( ) , lines , index ( ) ) ;
45- var nextTask = next . chapters [ 0 ] . pages [ 0 ] . tasks [ 0 ] ;
46- expect ( nextTask . description ) . to . equal ( 'Task One\nwith more on the next\nline' ) ;
55+ it ( 'should handle string literals' , function ( ) {
56+ var lines = [ '### Page One' , 'page description' , 'more page description' ,
57+ '@onComplete("next page' , '`var a = 42;`' , '")' ] ;
58+ var next = page ( result ( ) , lines , index ( ) ) ;
59+ var nextPage = next . chapters [ 0 ] . pages [ 0 ] ;
60+ expect ( nextPage ) . to . deep . equal ( {
61+ title : 'Page One' ,
62+ description : 'page description\nmore page description' ,
63+ onComplete : 'next page\n`var a = 42;`'
64+ } ) ;
4765 } ) ;
66+
67+ xit ( 'shouldn\'t add @onComplete string to a task' , function ( ) {
68+ var lines = [ '+ Task One' , 'with more on the next' , 'line' , '@onComplete("next page")' ] ;
69+ var next = task ( resultTask ( ) , lines , index ( ) ) ;
70+ var nextTask = next . chapters [ 0 ] . pages [ 0 ] . tasks [ 0 ] ;
71+ expect ( nextTask . description ) . to . equal ( 'Task One\nwith more on the next\nline' ) ;
4872 } ) ;
4973} ) ;
0 commit comments