Skip to content

Commit 8c9d85e

Browse files
committed
pushing a failing test for #356
1 parent 9aeb5db commit 8c9d85e

File tree

3 files changed

+61
-4
lines changed

3 files changed

+61
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{> test-styled-atom:test_1 }}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div class="test_group">
2+
{{#listItems.one}}
3+
{{> test-styled-atom }}
4+
{{/listItems.one}}
5+
</div>

test/list_item_hunter_tests.js

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
var pl = {
2121
"listitems": {
2222
"1": [
23-
{ "title": "Foo" }
23+
{ "title": "Foo" },
24+
{ "message" : "FooM"}
2425
],
2526
"2": [
2627
{ "title": "Foo" },
@@ -31,8 +32,16 @@
3132
"link": {},
3233
"partials": []
3334
},
34-
"config": {"debug": false},
35-
"partials" : {}
35+
"config": {
36+
"debug": false,
37+
"paths": {
38+
"source": {
39+
"patterns": "./test/files/_patterns"
40+
}
41+
}
42+
},
43+
"partials" : {},
44+
"patterns" : []
3645
};
3746

3847
return extend(pl, customProps);
@@ -335,7 +344,49 @@
335344
var expectedValue = '<div class="test_group"> <span class="test_base "> Foo </span> <span class="test_base test_1"> Foo </span> <span class="test_base "> Foo </span> <span class="test_base "> Bar </span> <span class="test_base test_1"> Bar </span> <span class="test_base "> Bar </span> </div>';
336345
test.equals(bookendPattern.extendedTemplate.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), expectedValue.trim());
337346
test.done();
338-
}
347+
},
348+
349+
'process_list_item_partials - correctly ignores already processed partial that had a style modifier when the same partial no longer has one' : function(test){
350+
//arrange
351+
var fs = require('fs-extra');
352+
var pa = require('../core/lib/pattern_assembler');
353+
var pattern_assembler = new pa();
354+
var list_item_hunter = new lih();
355+
var patterns_dir = './test/files/_patterns';
356+
357+
var pl = createFakePatternLab();
358+
359+
var atomPattern = new Pattern('00-test/03-styled-atom.mustache');
360+
atomPattern.template = fs.readFileSync(patterns_dir + '/00-test/03-styled-atom.mustache', 'utf8');
361+
atomPattern.extendedTemplate = atomPattern.template;
362+
atomPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(atomPattern);
363+
364+
var anotherStyledAtomPattern = new Pattern('00-test/12-another-styled-atom.mustache');
365+
anotherStyledAtomPattern.template = fs.readFileSync(patterns_dir + '/00-test/12-another-styled-atom.mustache', 'utf8');
366+
anotherStyledAtomPattern.extendedTemplate = anotherStyledAtomPattern.template;
367+
anotherStyledAtomPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(anotherStyledAtomPattern);
368+
369+
var listPattern = new Pattern('00-test/13-listitem.mustache');
370+
listPattern.template = fs.readFileSync(patterns_dir + '/00-test/13-listitem.mustache', 'utf8');
371+
listPattern.extendedTemplate = listPattern.template;
372+
listPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(listPattern);
373+
374+
pl.patterns.push(atomPattern);
375+
pl.patterns.push(anotherStyledAtomPattern);
376+
pl.patterns.push(listPattern);
377+
378+
//act
379+
380+
//might need to cal processPatternRecursive instead
381+
pattern_assembler.process_pattern_recursive(atomPattern.relPath, pl);
382+
pattern_assembler.process_pattern_recursive(anotherStyledAtomPattern.relPath, pl);
383+
pattern_assembler.process_pattern_recursive(listPattern.relPath, pl);
384+
385+
//assert.
386+
var expectedValue = '<div class="test_group"> <span class="test_base "> FooM </span> </div>';
387+
test.equals(listPattern.extendedTemplate.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), expectedValue.trim());
388+
test.done();
389+
},
339390

340391
};
341392

0 commit comments

Comments
 (0)