Skip to content

Commit 9f510b6

Browse files
author
e2tha-e
committed
unit tests for verbose mustache partials
1 parent c68968f commit 9f510b6

File tree

2 files changed

+162
-1
lines changed

2 files changed

+162
-1
lines changed

test/parameter_hunter_tests.js

Lines changed: 145 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,150 @@
149149
test.done();
150150
},
151151

152-
};
152+
'pattern hunter finds and extends templates with verbose partials' : function(test){
153+
154+
//setup current pattern from what we would have during execution
155+
var currentPattern = {
156+
"fileName": "01-sticky-comment",
157+
"subdir": "02-organisms/02-comments",
158+
"name": "02-organisms-02-comments-01-sticky-comment",
159+
"data": null,
160+
"jsonFileData": {},
161+
"patternName": "sticky-comment",
162+
"patternLink": "02-organisms-02-comments-01-sticky-comment/02-organisms-02-comments-01-sticky-comment.html",
163+
"patternGroup": "organisms",
164+
"patternSubGroup": "comments",
165+
"flatPatternPath": "02-organisms-02-comments",
166+
"key": "organisms-sticky-comment",
167+
"template": "{{> 01-molecules/06-components/02-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}",
168+
"patternPartial": "",
169+
"lineage": [
170+
],
171+
"lineageIndex": [
172+
],
173+
"lineageR": [
174+
],
175+
"lineageRIndex": [
176+
],
177+
"patternState": "",
178+
"extendedTemplate": "{{> 01-molecules/06-components/02-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}"
179+
};
180+
var patternlab = {
181+
patterns: [
182+
{
183+
"fileName": "02-single-comment",
184+
"subdir": "01-molecules/06-components",
185+
"name": "01-molecules-06-components-02-single-comment",
186+
"data": null,
187+
"jsonFileData": {},
188+
"patternName": "single-comment",
189+
"patternLink": "01-molecules-06-components-02-single-comment/01-molecules-06-components-02-single-comment.html",
190+
"patternGroup": "molecules",
191+
"patternSubGroup": "components",
192+
"flatPatternPath": "01-molecules-06-components",
193+
"key": "molecules-single-comment",
194+
"template": "<p>{{description}}</p>",
195+
"patternPartial": "",
196+
"lineage": [
197+
],
198+
"lineageIndex": [
199+
],
200+
"lineageR": [
201+
],
202+
"lineageRIndex": [
203+
],
204+
"patternState": "",
205+
"extendedTemplate": "<p>{{description}}</p>"
206+
}
207+
],
208+
config: {
209+
debug: false
210+
},
211+
data: {
212+
description: 'Not a quote from a smart man'
213+
}
214+
};
215+
216+
var parameter_hunter = new ph();
217+
218+
parameter_hunter.find_parameters(currentPattern, patternlab);
219+
test.equals(currentPattern.extendedTemplate, '<p>A life is like a garden. Perfect moments can be had, but not preserved, except in memory.</p>');
220+
221+
test.done();
222+
},
223+
224+
'pattern hunter finds and extends templates with fully-pathed partials' : function(test){
225+
226+
//setup current pattern from what we would have during execution
227+
var currentPattern = {
228+
"fileName": "01-sticky-comment",
229+
"subdir": "02-organisms/02-comments",
230+
"name": "02-organisms-02-comments-01-sticky-comment",
231+
"data": null,
232+
"jsonFileData": {},
233+
"patternName": "sticky-comment",
234+
"patternLink": "02-organisms-02-comments-01-sticky-comment/02-organisms-02-comments-01-sticky-comment.html",
235+
"patternGroup": "organisms",
236+
"patternSubGroup": "comments",
237+
"flatPatternPath": "02-organisms-02-comments",
238+
"key": "organisms-sticky-comment",
239+
"template": "{{> 01-molecules/06-components/02-single-comment.mustache(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}",
240+
"patternPartial": "",
241+
"lineage": [
242+
],
243+
"lineageIndex": [
244+
],
245+
"lineageR": [
246+
],
247+
"lineageRIndex": [
248+
],
249+
"patternState": "",
250+
"extendedTemplate": "{{> 01-molecules/06-components/02-single-comment.mustache(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}"
251+
};
252+
var patternlab = {
253+
patterns: [
254+
{
255+
"fileName": "02-single-comment",
256+
"subdir": "01-molecules/06-components",
257+
"name": "01-molecules-06-components-02-single-comment",
258+
"data": null,
259+
"jsonFileData": {},
260+
"patternName": "single-comment",
261+
"patternLink": "01-molecules-06-components-02-single-comment/01-molecules-06-components-02-single-comment.html",
262+
"patternGroup": "molecules",
263+
"patternSubGroup": "components",
264+
"flatPatternPath": "01-molecules-06-components",
265+
"key": "molecules-single-comment",
266+
"template": "<p>{{description}}</p>",
267+
"patternPartial": "",
268+
"lineage": [
269+
],
270+
"lineageIndex": [
271+
],
272+
"lineageR": [
273+
],
274+
"lineageRIndex": [
275+
],
276+
"patternState": "",
277+
"extendedTemplate": "<p>{{description}}</p>"
278+
}
279+
],
280+
config: {
281+
debug: false
282+
},
283+
data: {
284+
description: 'Not a quote from a smart man'
285+
}
286+
};
287+
288+
var parameter_hunter = new ph();
289+
290+
parameter_hunter.find_parameters(currentPattern, patternlab);
291+
test.equals(currentPattern.extendedTemplate, '<p>A life is like a garden. Perfect moments can be had, but not preserved, except in memory.</p>');
292+
293+
test.done();
294+
}
295+
296+
};
153297

154298
}());

test/pattern_assembler_tests.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@
1818
test.equals(results[0], '{{> molecules-comment-header}}');
1919
test.equals(results[1], '{{> molecules-single-comment(description: \'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.\') }}');
2020

21+
test.done();
22+
},
23+
24+
'find_pattern_partials finds verbose partials' : function(test){
25+
26+
//setup current pattern from what we would have during execution
27+
var currentPattern = {
28+
"template": "<h1>{{> 01-molecules/06-components/03-comment-header.mustache }}</h1><div>{{> 01-molecules/06-components/02-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}</div>",
29+
};
30+
31+
var pattern_assembler = new pa();
32+
33+
var results = pattern_assembler.find_pattern_partials(currentPattern);
34+
test.equals(results.length, 2);
35+
test.equals(results[0], '{{> 01-molecules/06-components/03-comment-header.mustache }}');
36+
test.equals(results[1], '{{> 01-molecules/06-components/02-single-comment(description: \'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.\') }}');
37+
2138
test.done();
2239
}
2340

0 commit comments

Comments
 (0)