Skip to content
This repository was archived by the owner on Dec 10, 2019. It is now read-only.

Commit fd3c4b5

Browse files
committed
unit test fixups, plus a tweak to the Mustache partial finder to permit
the verbose partial syntax without the .mustache file extension, as per http://patternlab.io/docs/pattern-including.html
1 parent 882aee2 commit fd3c4b5

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

builder/pattern_engines/engine_mustache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
engineFileExtension: '.mustache',
2020

2121
// regexes, stored here so they're only compiled once
22-
findPartialsRE: /{{>\s*((?:\d+-[\w-]+\/)+(\d+-[\w-]+\.\w+)|[A-Za-z0-9-]+)(\:[A-Za-z0-9-]+)?(\(\s*\w+\s*:\s*(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*")\))?\s*}}/g,
22+
findPartialsRE: /{{>\s*((?:\d+-[\w-]+\/)+(\d+-[\w-]+(\.\w+)?)|[A-Za-z0-9-]+)(\:[A-Za-z0-9-]+)?(\(\s*\w+\s*:\s*(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*")\))?\s*}}/g,
2323
findPartialsWithStyleModifiersRE: /{{>([ ])?([\w\-\.\/~]+)(?!\()(\:[A-Za-z0-9-_]+)+(?:(| )\(.*)?([ ])?}}/g,
2424
findPartialsWithPatternParametersRE: /{{>([ ])?([\w\-\.\/~]+)(?:\:[A-Za-z0-9-_]+)?(?:(| )\(.*)+([ ])?}}/g,
2525
findListItemsRE: /({{#( )?)(list(I|i)tems.)(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)( )?}}/g,

test/lineage_hunter_tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
var currentPattern = createFakeEmptyErrorPattern();
138138
extend(currentPattern, {
139139
"template": "{{>atoms-error(message: 'That\\'s no moon...')}}",
140-
"patternPartial": "{{>atoms-error(message: 'That\\'s no moon...')}}",
140+
"patternPartial": "{{>atoms-error(message: 'That\\'s no moon...')}}"
141141
});
142142

143143
var patternlab = {
@@ -219,4 +219,4 @@
219219

220220
};
221221

222-
}());
222+
})();

test/pattern_assembler_tests.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77

88
exports['pattern_assembler'] = {
99
'find_pattern_partials finds partials' : function(test){
10-
test.expect(13);
10+
// NOTES from GTP:
11+
// it's nice to have so much test coverage, but it retrospect, I'm not
12+
// happy with the structure I wound up with in this test; it's too
13+
// difficult to add test cases and test failure reporting is not very
14+
// granular.
15+
16+
test.expect(14);
1117

1218
//setup current pattern from what we would have during execution
1319
var currentPattern = of.oPattern.create(
@@ -29,13 +35,15 @@
2935
"{{> 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.') }}" +
3036
"{{> molecules-single-comment:foo }}" +
3137
"{{>atoms-error(message: 'That\\'s no moon...')}}" +
32-
'{{>atoms-error(message: \'That\\\'s no moon...\')}}'
38+
'{{>atoms-error(message: \'That\\\'s no moon...\')}}' +
39+
"{{> 00-atoms/00-global/ }}" +
40+
"{{> 00-atoms/00-global/06-test }}"
3341
}
3442
);
3543

3644
var results = currentPattern.findPartials();
3745
console.log(results);
38-
test.equals(results.length, 12);
46+
test.equals(results.length, 13);
3947
test.equals(results[0], "{{> molecules-comment-header}}");
4048
test.equals(results[1], "{{> molecules-comment-header}}");
4149
test.equals(results[2], "{{> \n molecules-comment-header\n}}");
@@ -48,6 +56,7 @@
4856
test.equals(results[9], "{{> molecules-single-comment:foo }}");
4957
test.equals(results[10], "{{>atoms-error(message: 'That\\'s no moon...')}}");
5058
test.equals(results[11], "{{>atoms-error(message: 'That\\'s no moon...')}}");
59+
test.equals(results[12], "{{> 00-atoms/00-global/06-test }}");
5160
test.done();
5261
},
5362

0 commit comments

Comments
 (0)