1
1
"use strict" ;
2
+ /*eslint-disable no-shadow*/
2
3
4
+ var test = require ( 'tape' ) ;
3
5
var path = require ( 'path' ) ;
4
6
var pa = require ( '../core/lib/pattern_assembler' ) ;
5
7
var Pattern = require ( '../core/lib/object_factory' ) . Pattern ;
6
8
var testPatternsPath = path . resolve ( __dirname , 'files' , '_patterns' ) ;
7
9
var eol = require ( 'os' ) . EOL ;
8
10
11
+ // don't run these tests unless mustache is installed
12
+ var engineLoader = require ( '../core/lib/pattern_engines' ) ;
13
+ if ( ! engineLoader . mustache ) {
14
+ test . only ( 'Mustache engine not installed, skipping tests.' , function ( test ) {
15
+ test . end ( ) ;
16
+ } ) ;
17
+ }
18
+
9
19
// fake pattern lab constructor:
10
20
// sets up a fake patternlab object, which is needed by the pattern processing
11
21
// apparatus.
@@ -33,7 +43,7 @@ function fakePatternLab() {
33
43
34
44
// function for testing sets of partials
35
45
function testFindPartials ( test , partialTests ) {
36
- test . expect ( partialTests . length + 1 ) ;
46
+ test . plan ( partialTests . length + 1 ) ;
37
47
38
48
// setup current pattern from what we would have during execution
39
49
// docs on partial syntax are here:
@@ -55,11 +65,11 @@ function testFindPartials(test, partialTests) {
55
65
test . equals ( results [ index ] , testString ) ;
56
66
} ) ;
57
67
58
- test . done ( ) ;
68
+ test . end ( ) ;
59
69
}
60
70
61
71
function testFindPartialsWithStyleModifiers ( test , partialTests ) {
62
- test . expect ( partialTests . length + 1 ) ;
72
+ test . plan ( partialTests . length + 1 ) ;
63
73
64
74
// setup current pattern from what we would have during execution
65
75
// docs on partial syntax are here:
@@ -81,11 +91,11 @@ function testFindPartialsWithStyleModifiers(test, partialTests) {
81
91
test . equals ( results [ index ] , testString ) ;
82
92
} ) ;
83
93
84
- test . done ( ) ;
94
+ test . end ( ) ;
85
95
}
86
96
87
97
function testFindPartialsWithPatternParameters ( test , partialTests ) {
88
- test . expect ( partialTests . length + 1 ) ;
98
+ test . plan ( partialTests . length + 1 ) ;
89
99
90
100
// setup current pattern from what we would have during execution
91
101
// docs on partial syntax are here:
@@ -107,110 +117,106 @@ function testFindPartialsWithPatternParameters(test, partialTests) {
107
117
test . equals ( results [ index ] , testString ) ;
108
118
} ) ;
109
119
110
- test . done ( ) ;
120
+ test . end ( ) ;
111
121
}
112
122
113
- exports [ 'engine_mustache' ] = {
114
- 'find_pattern_partials finds one simple partial' : function ( test ) {
115
- testFindPartials ( test , [
116
- "{{> molecules-comment-header}}"
117
- ] ) ;
118
- } ,
119
-
120
- 'find_pattern_partials finds simple partials under stressed circumstances' : function ( test ) {
121
- testFindPartials ( test , [
122
- "{{>molecules-comment-header}}" ,
123
- "{{> " + eol + " molecules-comment-header" + eol + "}}" ,
124
- "{{> molecules-weird-spacing }}"
125
- ] ) ;
126
- } ,
127
-
128
- 'find_pattern_partials finds one simple verbose partial' : function ( test ) {
129
- testFindPartials ( test , [
130
- '{{> 00-atoms/00-global/06-test }}'
131
- ] ) ;
132
- } ,
133
-
134
- 'find_pattern_partials finds partials with parameters' : function ( test ) {
135
- testFindPartials ( test , [
136
- "{{> molecules-single-comment(description: true) }}" ,
137
- "{{> molecules-single-comment(description: 42) }}" ,
138
- "{{> molecules-single-comment(description: '42') }}" ,
139
- "{{> molecules-single-comment(description: \"42\") }}" ,
140
- "{{> molecules-single-comment(description: 'test', anotherThing: 'retest') }}" ,
141
- "{{> molecules-single-comment(description: false, anotherThing: \"retest\") }}" ,
142
- '{{> molecules-single-comment(description:"A life is like a \"garden\". Perfect moments can be had, but not preserved, except in memory.") }}'
143
- ] ) ;
144
- } ,
145
-
146
- 'find_pattern_partials finds simple partials with style modifiers' : function ( test ) {
147
- testFindPartials ( test , [
148
- '{{> molecules-single-comment:foo }}' ,
149
- '{{> molecules-single-comment:foo|bar }}'
150
- ] ) ;
151
- } ,
152
- 'find_pattern_partials finds mixed partials' : function ( test ) {
153
- testFindPartials ( test , [
154
- '{{> molecules-single-comment:foo(description: "test", anotherThing: true) }}' ,
155
- '{{> molecules-single-comment:foo|bar(description: true) }}'
156
- ] ) ;
157
- } ,
158
-
159
- 'find_pattern_partials finds one simple partial with styleModifier' : function ( test ) {
160
- testFindPartialsWithStyleModifiers ( test , [
161
- "{{> molecules-comment-header:test}}"
162
- ] ) ;
163
- } ,
164
- 'find_pattern_partials finds partial with many styleModifiers' : function ( test ) {
165
- testFindPartialsWithStyleModifiers ( test , [
166
- "{{> molecules-comment-header:test|test2|test3}}"
167
- ] ) ;
168
- } ,
169
- 'find_pattern_partials finds partials with differing styleModifiers' : function ( test ) {
170
- testFindPartialsWithStyleModifiers ( test , [
171
- "{{> molecules-comment-header:test|test2|test3}}" ,
172
- "{{> molecules-comment-header:foo-1}}" ,
173
- "{{> molecules-comment-header:bar_1}}"
174
- ] ) ;
175
- } ,
176
- 'find_pattern_partials finds partials with styleModifiers when parameters present' : function ( test ) {
177
- testFindPartialsWithStyleModifiers ( test , [
178
- "{{> molecules-comment-header:test|test2|test3(description: true)}}" ,
179
- "{{> molecules-comment-header:foo-1(description: 'foo')}}" ,
180
- "{{> molecules-comment-header:bar_1(descrition: 'bar', anotherThing: 10102010) }}"
181
- ] ) ;
182
- } ,
183
-
184
- 'find_pattern_partials_with_parameters finds one simple partial with parameters' : function ( test ) {
185
- testFindPartialsWithPatternParameters ( test , [
186
- "{{> molecules-comment-header(description: 'test')}}"
187
- ] ) ;
188
- } ,
189
- 'find_pattern_partials_with_parameters finds partials with parameters' : function ( test ) {
190
- testFindPartialsWithPatternParameters ( test , [
191
- "{{> molecules-single-comment(description: true) }}" ,
192
- "{{> molecules-single-comment(description: 42) }}" ,
193
- "{{> molecules-single-comment(description: '42') }}" ,
194
- "{{> molecules-single-comment(description: \"42\") }}" ,
195
- "{{> molecules-single-comment(description: 'test', anotherThing: 'retest') }}" ,
196
- "{{> molecules-single-comment(description: false, anotherThing: \"retest\") }}" ,
197
- '{{> molecules-single-comment(description:"A life is like a \"garden\". Perfect moments can be had, but not preserved, except in memory.") }}'
198
- ] ) ;
199
- } ,
200
- 'find_pattern_partials finds partials with parameters when styleModifiers present' : function ( test ) {
201
- testFindPartialsWithPatternParameters ( test , [
202
- "{{> molecules-comment-header:test|test2|test3(description: true)}}" ,
203
- "{{> molecules-comment-header:foo-1(description: 'foo')}}" ,
204
- "{{> molecules-comment-header:bar_1(descrition: 'bar', anotherThing: 10102010) }}"
205
- ] ) ;
206
- }
207
-
208
- } ;
209
123
210
-
211
- // don't run these tests unless mustache is installed
212
- var engineLoader = require ( '../core/lib/pattern_engines' ) ;
213
- if ( ! engineLoader . mustache ) {
214
- console . log ( "Mustache engine not installed, skipping tests." ) ;
215
- delete exports . engine_mustache ;
216
- }
124
+ test ( 'find_pattern_partials finds one simple partial' , function ( test ) {
125
+ testFindPartials ( test , [
126
+ "{{> molecules-comment-header}}"
127
+ ] ) ;
128
+ } ) ;
129
+
130
+ test ( 'find_pattern_partials finds simple partials under stressed circumstances' , function ( test ) {
131
+ testFindPartials ( test , [
132
+ "{{>molecules-comment-header}}" ,
133
+ "{{> " + eol + " molecules-comment-header" + eol + "}}" ,
134
+ "{{> molecules-weird-spacing }}"
135
+ ] ) ;
136
+ } ) ;
137
+
138
+ test ( 'find_pattern_partials finds one simple verbose partial' , function ( test ) {
139
+ testFindPartials ( test , [
140
+ '{{> 00-atoms/00-global/06-test }}'
141
+ ] ) ;
142
+ } ) ;
143
+
144
+ test ( 'find_pattern_partials finds partials with parameters' , function ( test ) {
145
+ testFindPartials ( test , [
146
+ "{{> molecules-single-comment(description: true) }}" ,
147
+ "{{> molecules-single-comment(description: 42) }}" ,
148
+ "{{> molecules-single-comment(description: '42') }}" ,
149
+ "{{> molecules-single-comment(description: \"42\") }}" ,
150
+ "{{> molecules-single-comment(description: 'test', anotherThing: 'retest') }}" ,
151
+ "{{> molecules-single-comment(description: false, anotherThing: \"retest\") }}" ,
152
+ '{{> molecules-single-comment(description:"A life is like a \"garden\". Perfect moments can be had, but not preserved, except in memory.") }}'
153
+ ] ) ;
154
+ } ) ;
155
+
156
+ test ( 'find_pattern_partials finds simple partials with style modifiers' , function ( test ) {
157
+ testFindPartials ( test , [
158
+ '{{> molecules-single-comment:foo }}' ,
159
+ '{{> molecules-single-comment:foo|bar }}'
160
+ ] ) ;
161
+ } ) ;
162
+
163
+ test ( 'find_pattern_partials finds mixed partials' , function ( test ) {
164
+ testFindPartials ( test , [
165
+ '{{> molecules-single-comment:foo(description: "test", anotherThing: true) }}' ,
166
+ '{{> molecules-single-comment:foo|bar(description: true) }}'
167
+ ] ) ;
168
+ } ) ;
169
+
170
+ test ( 'find_pattern_partials finds one simple partial with styleModifier' , function ( test ) {
171
+ testFindPartialsWithStyleModifiers ( test , [
172
+ "{{> molecules-comment-header:test}}"
173
+ ] ) ;
174
+ } ) ;
175
+
176
+ test ( 'find_pattern_partials finds partial with many styleModifiers' , function ( test ) {
177
+ testFindPartialsWithStyleModifiers ( test , [
178
+ "{{> molecules-comment-header:test|test2|test3}}"
179
+ ] ) ;
180
+ } ) ;
181
+
182
+ test ( 'find_pattern_partials finds partials with differing styleModifiers' , function ( test ) {
183
+ testFindPartialsWithStyleModifiers ( test , [
184
+ "{{> molecules-comment-header:test|test2|test3}}" ,
185
+ "{{> molecules-comment-header:foo-1}}" ,
186
+ "{{> molecules-comment-header:bar_1}}"
187
+ ] ) ;
188
+ } ) ;
189
+
190
+ test ( 'find_pattern_partials finds partials with styleModifiers when parameters present' , function ( test ) {
191
+ testFindPartialsWithStyleModifiers ( test , [
192
+ "{{> molecules-comment-header:test|test2|test3(description: true)}}" ,
193
+ "{{> molecules-comment-header:foo-1(description: 'foo')}}" ,
194
+ "{{> molecules-comment-header:bar_1(descrition: 'bar', anotherThing: 10102010) }}"
195
+ ] ) ;
196
+ } ) ;
197
+
198
+ test ( 'find_pattern_partials_with_parameters finds one simple partial with parameters' , function ( test ) {
199
+ testFindPartialsWithPatternParameters ( test , [
200
+ "{{> molecules-comment-header(description: 'test')}}"
201
+ ] ) ;
202
+ } ) ;
203
+
204
+ test ( 'find_pattern_partials_with_parameters finds partials with parameters' , function ( test ) {
205
+ testFindPartialsWithPatternParameters ( test , [
206
+ "{{> molecules-single-comment(description: true) }}" ,
207
+ "{{> molecules-single-comment(description: 42) }}" ,
208
+ "{{> molecules-single-comment(description: '42') }}" ,
209
+ "{{> molecules-single-comment(description: \"42\") }}" ,
210
+ "{{> molecules-single-comment(description: 'test', anotherThing: 'retest') }}" ,
211
+ "{{> molecules-single-comment(description: false, anotherThing: \"retest\") }}" ,
212
+ '{{> molecules-single-comment(description:"A life is like a \"garden\". Perfect moments can be had, but not preserved, except in memory.") }}'
213
+ ] ) ;
214
+ } ) ;
215
+
216
+ test ( 'find_pattern_partials finds partials with parameters when styleModifiers present' , function ( test ) {
217
+ testFindPartialsWithPatternParameters ( test , [
218
+ "{{> molecules-comment-header:test|test2|test3(description: true)}}" ,
219
+ "{{> molecules-comment-header:foo-1(description: 'foo')}}" ,
220
+ "{{> molecules-comment-header:bar_1(descrition: 'bar', anotherThing: 10102010) }}"
221
+ ] ) ;
222
+ } ) ;
0 commit comments