@@ -23,12 +23,22 @@ describe('@onComplete', function() {
2323 return {
2424 chapters : [ {
2525 pages : [ {
26+ title : '' ,
27+ description : '' ,
2628 tasks : [ ]
2729 } ]
2830 } ]
2931 } ;
3032 } ;
3133
34+ var indexTask = function ( ) {
35+ return {
36+ chapter : 0 ,
37+ page : 0 ,
38+ task : - 1
39+ } ;
40+ } ;
41+
3242 it ( 'should add @onComplete string to the page' , function ( ) {
3343 var lines = [ '### Page One' , 'page description' , 'more page description' , '@onComplete("next page")' ] ;
3444 var next = page ( result ( ) , lines , index ( ) ) ;
@@ -42,7 +52,8 @@ describe('@onComplete', function() {
4252
4353 it ( 'should handle multi-line codeblocks' , function ( ) {
4454 var lines = [ '### Page One' , 'page description' , 'more page description' ,
45- '@onComplete("next page' , '```' , 'var a = 42;' , '```' , '")' ] ;
55+ '@onComplete("next page' , '```' , 'var a = 42;' , '```' , '")'
56+ ] ;
4657 var next = page ( result ( ) , lines , index ( ) ) ;
4758 var nextPage = next . chapters [ 0 ] . pages [ 0 ] ;
4859 expect ( nextPage ) . to . deep . equal ( {
@@ -52,22 +63,24 @@ describe('@onComplete', function() {
5263 } ) ;
5364 } ) ;
5465
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- } ) ;
66+ it ( 'should handle string literals' , function ( ) {
67+ var lines = [ '### Page One' , 'page description' , 'more page description' ,
68+ '@onComplete("next page' , '`var a = 42;`' , '")'
69+ ] ;
70+ var next = page ( result ( ) , lines , index ( ) ) ;
71+ var nextPage = next . chapters [ 0 ] . pages [ 0 ] ;
72+ expect ( nextPage ) . to . deep . equal ( {
73+ title : 'Page One ' ,
74+ description : 'page description\nmore page description' ,
75+ onComplete : 'next page\n`var a = 42;`'
6576 } ) ;
77+ } ) ;
6678
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 ( ) ) ;
79+ it ( 'shouldn\'t add to tasks ' , function ( ) {
80+ var lines = [ '+ Task One' , 'with more on the next' , 'line' ] ;
81+ var next = task ( resultTask ( ) , lines , indexTask ( ) ) ;
7082 var nextTask = next . chapters [ 0 ] . pages [ 0 ] . tasks [ 0 ] ;
7183 expect ( nextTask . description ) . to . equal ( 'Task One\nwith more on the next\nline' ) ;
7284 } ) ;
85+
7386} ) ;
0 commit comments