|
20 | 20 | var pl = {
|
21 | 21 | "listitems": {
|
22 | 22 | "1": [
|
23 |
| - { "title": "Foo" } |
| 23 | + { "title": "Foo" }, |
| 24 | + { "message" : "FooM"} |
24 | 25 | ],
|
25 | 26 | "2": [
|
26 | 27 | { "title": "Foo" },
|
|
31 | 32 | "link": {},
|
32 | 33 | "partials": []
|
33 | 34 | },
|
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" : [] |
36 | 45 | };
|
37 | 46 |
|
38 | 47 | return extend(pl, customProps);
|
|
335 | 344 | 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>';
|
336 | 345 | test.equals(bookendPattern.extendedTemplate.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), expectedValue.trim());
|
337 | 346 | 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 | + }, |
339 | 390 |
|
340 | 391 | };
|
341 | 392 |
|
|
0 commit comments