@@ -21,37 +21,112 @@ function hasPattern(pattern, shouldExists, callback) {
2121 } else {
2222 callback ( shouldExists ? null : 'Pattern ' + pattern + ' WAS found. This is NOT expected.' ) ;
2323 }
24-
2524 }
2625 } ) ;
2726}
2827
28+ function contain ( pattern , callback ) {
29+ hasPattern ( pattern , true , callback ) ;
30+ }
31+
32+ function notContain ( pattern , callback ) {
33+ hasPattern ( pattern , false , callback ) ;
34+ }
35+
2936describe ( 'markdown-snippet-injector' , function ( ) {
3037
3138 beforeEach ( function ( done ) {
3239 preparedemo ( ) ;
3340 done ( ) ;
3441 } ) ;
3542
36- //TODO: Add tests for hidden fields
43+ describe ( 'XML' ,
44+ function ( ) {
45+ it ( 'should process XML snippets' , function ( done ) {
46+ shelljs . exec ( 'node index.js --root=./test/root --docsroot=./test/docsroot-output --sourceext=".xml"' ) ;
47+ notContain ( "<snippet id='xml-snippet'/>" , function ( ) {
48+ notContain ( "<snippet id='xml-snippet'>" , function ( ) {
49+ contain ( '<Label fontSize="20" text="{{ itemName }}"/>' , done ) ;
50+ } ) ;
51+ } ) ;
52+ } ) ;
3753
38- it ( 'should process XML snippets' , function ( done ) {
39- shelljs . exec ( 'node index.js --root=./test/root --docsroot=./test/docsroot-output --sourceext=".xml"' ) ;
40- hasPattern ( "<snippet id='xml-snippet'/>" , false , done ) ;
41- } ) ;
54+ it ( 'should process XML snippets and wrap it' , function ( done ) {
55+ shelljs . exec ( 'node index.js -w --root=./test/root --docsroot=./test/docsroot-output --sourceext=".xml"' ) ;
56+ notContain ( "<snippet id='xml-snippet'/>" , function ( ) {
57+ contain ( "<snippet id='xml-snippet'>" , function ( ) {
58+ contain ( '<Label fontSize="20" text="{{ itemName }}"/>' , done ) ;
59+ } ) ;
60+ } ) ;
61+ } ) ;
62+ } ) ;
4263
43- it ( 'should process TypeScript snippets' , function ( done ) {
44- shelljs . exec ( 'node index.js --root=./test/root --docsroot=./test/docsroot-output --sourceext=".ts"' ) ;
45- hasPattern ( "<snippet id='ts-snippet'/>" , false , done ) ;
46- } ) ;
64+ describe ( 'TypeScript' ,
65+ function ( ) {
66+ it ( 'should process TypeScript snippets' , function ( done ) {
67+ shelljs . exec ( 'node index.js --root=./test/root --docsroot=./test/docsroot-output --sourceext=".ts"' ) ;
68+ notContain ( "<snippet id='ts-snippet'/>" , function ( ) {
69+ notContain ( "<snippet id='ts-snippet'>" , function ( ) {
70+ notContain ( "</snippet>" , function ( ) {
71+ contain ( 'return a + b;' , done ) ;
72+ } ) ;
73+ } ) ;
74+ } ) ;
75+ } ) ;
4776
48- it ( 'should process CSS snippets' , function ( done ) {
49- shelljs . exec ( 'node index.js --root=./test/root --docsroot=./test/docsroot-output --sourceext=".css"' ) ;
50- hasPattern ( "<snippet id='css-snippet'/>" , false , done ) ;
51- } ) ;
77+ it ( 'should process TypeScript snippets and wrap' , function ( done ) {
78+ shelljs . exec ( 'node index.js -w --root=./test/root --docsroot=./test/docsroot-output --sourceext=".ts"' ) ;
79+ notContain ( "<snippet id='ts-snippet'/>" , function ( ) {
80+ contain ( "<snippet id='ts-snippet'>" , function ( ) {
81+ contain ( "</snippet>" , done ) ;
82+ } ) ;
83+ } ) ;
84+ } ) ;
85+ } ) ;
5286
53- it ( 'should NOT process snippetIds that are not defined in source' , function ( done ) {
54- shelljs . exec ( 'node index.js --root=./test/root --docsroot=./test/docsroot-output --sourceext=".css"' ) ;
55- hasPattern ( "<snippet id='cssSnippet'/>" , true , done ) ;
56- } ) ;
87+ describe ( 'CSS' ,
88+ function ( ) {
89+ it ( 'should process CSS snippets' , function ( done ) {
90+ shelljs . exec ( 'node index.js --root=./test/root --docsroot=./test/docsroot-output --sourceext=".css"' ) ;
91+ notContain ( "<snippet id='css-snippet'/>" , function ( ) {
92+ notContain ( "<snippet id='css-snippet'>" , function ( ) {
93+ notContain ( "</snippet>" , function ( ) {
94+ contain ( 'text-align: center;' , done ) ;
95+ } ) ;
96+ } ) ;
97+ } ) ;
98+ } ) ;
99+
100+ it ( 'should process CSS snippets and wrap' , function ( done ) {
101+ shelljs . exec ( 'node index.js -w --root=./test/root --docsroot=./test/docsroot-output --sourceext=".css"' ) ;
102+ notContain ( "<snippet id='css-snippet'/>" , function ( ) {
103+ contain ( "<snippet id='css-snippet'>" , function ( ) {
104+ contain ( "</snippet>" , function ( ) {
105+ contain ( 'text-align: center;' , done ) ;
106+ } ) ;
107+ } ) ;
108+ } ) ;
109+ } ) ;
110+
111+ it ( 'should keep hidden the marked area in CSS' , function ( done ) {
112+ shelljs . exec ( 'node index.js --root=./test/root --docsroot=./test/docsroot-output --sourceext=".css"' ) ;
113+ notContain ( "visibility: hidden;" , done ) ;
114+ } ) ;
115+
116+ it ( 'should NOT process snippetIds that are not defined in source' , function ( done ) {
117+ shelljs . exec ( 'node index.js --root=./test/root --docsroot=./test/docsroot-output --sourceext=".css"' ) ;
118+ contain ( "<snippet id='cssSnippet'/>" , function ( ) {
119+ notContain ( "<snippet id='cssSnippet'>" , done ) ;
120+ } ) ;
121+ } ) ;
122+
123+ it ( 'should update the already processed snippet tags' , function ( done ) {
124+ shelljs . exec ( 'node index.js --root=./test/root --docsroot=./test/docsroot-output --sourceext=".css"' ) ;
125+ contain ( "<snippet id='css-already-processed'>" , function ( ) {
126+ contain ( "</snippet>" , function ( ) {
127+ contain ( "color: red;" , done ) ;
128+ } ) ;
129+ } ) ;
130+ } ) ;
131+ } ) ;
57132} ) ;
0 commit comments