|
303 | 303 | atomPattern.template = fs.readFileSync(patterns_dir + '/00-test/03-styled-atom.mustache', 'utf8'); |
304 | 304 | atomPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(atomPattern); |
305 | 305 |
|
306 | | - |
307 | 306 | var groupPattern = new object_factory.oPattern('test/files/_patterns/00-test/04-group.mustache', '00-test', '04-group.mustache'); |
308 | 307 | groupPattern.template = fs.readFileSync(patterns_dir + '/00-test/04-group.mustache', 'utf8'); |
309 | 308 | groupPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(groupPattern); |
|
313 | 312 |
|
314 | 313 | //act |
315 | 314 | pattern_assembler.process_pattern_recursive('test/files/_patterns/00-test/04-group.mustache', pl, {}); |
| 315 | + |
316 | 316 | //assert |
317 | 317 | var expectedValue = '<div class="test_group"> <span class="test_base test_1"> {{message}} </span> <span class="test_base test_2"> {{message}} </span> <span class="test_base test_3"> {{message}} </span> <span class="test_base test_4"> {{message}} </span> </div>'; |
318 | 318 | test.equals(groupPattern.extendedTemplate.replace(/\s\s+/g, ' ').trim(), expectedValue.trim()); |
319 | 319 | test.done(); |
| 320 | + }, |
| 321 | + 'processPatternRecursive - correctly ignores a partial without a style modifier when the same partial later has a style modifier' : function(test){ |
| 322 | + //arrange |
| 323 | + var fs = require('fs-extra'); |
| 324 | + var pattern_assembler = new pa(); |
| 325 | + |
| 326 | + var pl = {}; |
| 327 | + pl.config = {}; |
| 328 | + pl.data = {}; |
| 329 | + pl.data.link = {}; |
| 330 | + pl.config.debug = false; |
| 331 | + pl.patterns = []; |
| 332 | + var patterns_dir = './test/files/_patterns'; |
| 333 | + |
| 334 | + var atomPattern = new object_factory.oPattern('test/files/_patterns/00-test/03-styled-atom.mustache', '00-test', '03-styled-atom.mustache'); |
| 335 | + atomPattern.template = fs.readFileSync(patterns_dir + '/00-test/03-styled-atom.mustache', 'utf8'); |
| 336 | + atomPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(atomPattern); |
| 337 | + |
| 338 | + var mixedPattern = new object_factory.oPattern('test/files/_patterns/00-test/06-mixed.mustache', '00-test', '06-mixed.mustache'); |
| 339 | + mixedPattern.template = fs.readFileSync(patterns_dir + '/00-test/06-mixed.mustache', 'utf8'); |
| 340 | + mixedPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(mixedPattern); |
| 341 | + |
| 342 | + pl.patterns.push(atomPattern); |
| 343 | + pl.patterns.push(mixedPattern); |
| 344 | + |
| 345 | + //act |
| 346 | + pattern_assembler.process_pattern_recursive('test/files/_patterns/00-test/06-mixed.mustache', pl, {}); |
| 347 | + |
| 348 | + //assert. here we expect {{styleModifier}} to be in the first group, since it was not replaced by anything. rendering with data will then remove this (correctly) |
| 349 | + var expectedValue = '<div class="test_group"> <span class="test_base {{styleModifier}}"> {{message}} </span> <span class="test_base test_2"> {{message}} </span> <span class="test_base test_3"> {{message}} </span> <span class="test_base test_4"> {{message}} </span> </div>'; |
| 350 | + test.equals(mixedPattern.extendedTemplate.replace(/\s\s+/g, ' ').trim(), expectedValue.trim()); |
| 351 | + test.done(); |
320 | 352 | } |
321 | 353 | }; |
322 | 354 | }()); |
0 commit comments