|
22 | 22 |
|
23 | 23 | test.done();
|
24 | 24 | },
|
25 |
| - |
26 | 25 | 'find_pattern_partials finds verbose partials' : function(test){
|
27 | 26 |
|
28 | 27 | //setup current pattern from what we would have during execution
|
|
39 | 38 |
|
40 | 39 | test.done();
|
41 | 40 | },
|
42 |
| - |
43 | 41 | 'find_pattern_partials_with_style_modifiers finds style modifiers' : function(test){
|
44 | 42 |
|
45 | 43 | //setup current pattern from what we would have during execution
|
|
55 | 53 |
|
56 | 54 | test.done();
|
57 | 55 | },
|
58 |
| - |
59 | 56 | 'find_pattern_partials_with_style_modifiers finds style modifiers with parameters present too' : function(test){
|
60 | 57 |
|
61 | 58 | //setup current pattern from what we would have during execution
|
|
71 | 68 |
|
72 | 69 | test.done();
|
73 | 70 | },
|
74 |
| - |
75 | 71 | 'find_pattern_partials_with_style_modifiers finds style modifiers with verbose partials' : function(test){
|
76 | 72 |
|
77 | 73 | //setup current pattern from what we would have during execution
|
|
87 | 83 |
|
88 | 84 | test.done();
|
89 | 85 | },
|
90 |
| - |
91 | 86 | 'find_pattern_partials_with_style_modifiers finds no style modifiers when only partials present' : function(test){
|
92 | 87 |
|
93 | 88 | //setup current pattern from what we would have during execution
|
|
102 | 97 |
|
103 | 98 | test.done();
|
104 | 99 | },
|
105 |
| - |
106 | 100 | 'find_pattern_partials_with_style_modifiers finds no style modifiers when only partials with pattern parameters present' : function(test){
|
107 | 101 |
|
108 | 102 | //setup current pattern from what we would have during execution
|
|
117 | 111 |
|
118 | 112 | test.done();
|
119 | 113 | },
|
120 |
| - |
121 | 114 | 'find_pattern_partials_with_parameters finds parameters' : function(test){
|
122 | 115 |
|
123 | 116 | //setup current pattern from what we would have during execution
|
|
134 | 127 | test.done();
|
135 | 128 |
|
136 | 129 | },
|
137 |
| - |
138 | 130 | 'find_pattern_partials_with_parameters finds parameters when stylemodifiers present too' : function(test){
|
139 | 131 |
|
140 | 132 | //setup current pattern from what we would have during execution
|
|
151 | 143 | test.done();
|
152 | 144 |
|
153 | 145 | },
|
154 |
| - |
155 | 146 | 'find_pattern_partials_with_parameters finds parameters with verbose partials' : function(test){
|
156 | 147 |
|
157 | 148 | //setup current pattern from what we would have during execution
|
|
168 | 159 | test.done();
|
169 | 160 |
|
170 | 161 | },
|
171 |
| - |
172 | 162 | 'find_pattern_partials_with_parameters finds no style modifiers when only partials present' : function(test){
|
173 | 163 |
|
174 | 164 | //setup current pattern from what we would have during execution
|
|
183 | 173 |
|
184 | 174 | test.done();
|
185 | 175 | },
|
186 |
| - |
187 | 176 | 'find_pattern_partials_with_parameters finds no style modifiers when only partials with style modifiers present' : function(test){
|
188 | 177 |
|
189 | 178 | //setup current pattern from what we would have during execution
|
|
198 | 187 |
|
199 | 188 | test.done();
|
200 | 189 | },
|
201 |
| - |
202 | 190 | 'process_pattern_recursive recursively includes partials' : function(test){
|
203 | 191 |
|
204 | 192 | //tests inclusion of partial that will be discovered by diveSync later in iteration than parent
|
|
306 | 294 | pl.data.link = {};
|
307 | 295 | pl.config.debug = false;
|
308 | 296 | pl.patterns = [];
|
| 297 | + pl.partials = {}; |
309 | 298 |
|
310 | 299 | var atomPattern = new object_factory.oPattern('test/files/_patterns/00-test/03-styled-atom.mustache', '00-test', '03-styled-atom.mustache');
|
311 | 300 | atomPattern.template = fs.readFileSync(patterns_dir + '/00-test/03-styled-atom.mustache', 'utf8');
|
|
315 | 304 | groupPattern.template = fs.readFileSync(patterns_dir + '/00-test/04-group.mustache', 'utf8');
|
316 | 305 | groupPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(groupPattern);
|
317 | 306 |
|
318 |
| - pl.patterns.push(atomPattern); |
319 |
| - pl.patterns.push(groupPattern); |
| 307 | + pattern_assembler.addPattern(atomPattern, pl); |
| 308 | + pattern_assembler.addPattern(groupPattern, pl); |
320 | 309 |
|
321 | 310 | //act
|
322 | 311 | pattern_assembler.process_pattern_recursive('test/files/_patterns/00-test/04-group.mustache', pl, {});
|
|
344 | 333 | pl.data.link = {};
|
345 | 334 | pl.config.debug = false;
|
346 | 335 | pl.patterns = [];
|
| 336 | + pl.partials = {}; |
347 | 337 |
|
348 | 338 | var atomPattern = new object_factory.oPattern('test/files/_patterns/00-test/03-styled-atom.mustache', '00-test', '03-styled-atom.mustache');
|
349 | 339 | atomPattern.template = fs.readFileSync(patterns_dir + '/00-test/03-styled-atom.mustache', 'utf8');
|
|
355 | 345 | groupPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(groupPattern);
|
356 | 346 | groupPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(groupPattern);
|
357 | 347 |
|
358 |
| - pl.patterns.push(atomPattern); |
359 |
| - pl.patterns.push(groupPattern); |
| 348 | + pattern_assembler.addPattern(atomPattern, pl); |
| 349 | + pattern_assembler.addPattern(groupPattern, pl); |
360 | 350 |
|
361 | 351 | //act
|
362 | 352 | pattern_assembler.process_pattern_recursive('test/files/_patterns/00-test/10-multiple-classes-numeric.mustache', pl, {});
|
|
384 | 374 | pl.data.link = {};
|
385 | 375 | pl.config.debug = false;
|
386 | 376 | pl.patterns = [];
|
| 377 | + pl.partials = {}; |
387 | 378 |
|
388 | 379 | var atomPattern = new object_factory.oPattern('test/files/_patterns/00-test/03-styled-atom.mustache', '00-test', '03-styled-atom.mustache');
|
389 | 380 | atomPattern.template = fs.readFileSync(patterns_dir + '/00-test/03-styled-atom.mustache', 'utf8');
|
|
393 | 384 | mixedPattern.template = fs.readFileSync(patterns_dir + '/00-test/06-mixed.mustache', 'utf8');
|
394 | 385 | mixedPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(mixedPattern);
|
395 | 386 |
|
396 |
| - pl.patterns.push(atomPattern); |
397 |
| - pl.patterns.push(mixedPattern); |
| 387 | + pattern_assembler.addPattern(atomPattern, pl); |
| 388 | + pattern_assembler.addPattern(mixedPattern, pl); |
398 | 389 |
|
399 | 390 | //act
|
400 | 391 | pattern_assembler.process_pattern_recursive('test/files/_patterns/00-test/06-mixed.mustache', pl, {});
|
|
422 | 413 | pl.data.link = {};
|
423 | 414 | pl.config.debug = false;
|
424 | 415 | pl.patterns = [];
|
| 416 | + pl.partials = {}; |
425 | 417 |
|
426 | 418 | var atomPattern = new object_factory.oPattern('test/files/_patterns/00-test/03-styled-atom.mustache', '00-test', '03-styled-atom.mustache');
|
427 | 419 | atomPattern.template = fs.readFileSync(patterns_dir + '/00-test/03-styled-atom.mustache', 'utf8');
|
|
431 | 423 | bookendPattern.template = fs.readFileSync(patterns_dir + '/00-test/09-bookend.mustache', 'utf8');
|
432 | 424 | bookendPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(bookendPattern);
|
433 | 425 |
|
434 |
| - pl.patterns.push(atomPattern); |
435 |
| - pl.patterns.push(bookendPattern); |
| 426 | + pattern_assembler.addPattern(atomPattern, pl); |
| 427 | + pattern_assembler.addPattern(bookendPattern, pl); |
436 | 428 |
|
437 | 429 | //act
|
438 | 430 | pattern_assembler.process_pattern_recursive('test/files/_patterns/00-test/09-bookend.mustache', pl, {});
|
|
460 | 452 | pl.data.link = {};
|
461 | 453 | pl.config.debug = false;
|
462 | 454 | pl.patterns = [];
|
| 455 | + pl.partials = {}; |
463 | 456 |
|
464 | 457 | var atomPattern = new object_factory.oPattern('test/files/_patterns/00-test/03-styled-atom.mustache', '00-test', '03-styled-atom.mustache');
|
465 | 458 | atomPattern.template = fs.readFileSync(patterns_dir + '/00-test/03-styled-atom.mustache', 'utf8');
|
466 | 459 | atomPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(atomPattern);
|
467 |
| - atomPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(atomPattern); |
| 460 | + atomPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(atomPattern); |
468 | 461 |
|
469 | 462 | var mixedPattern = new object_factory.oPattern('test/files/_patterns/00-test/07-mixed-params.mustache', '00-test', '07-mixed-params.mustache');
|
470 | 463 | mixedPattern.template = fs.readFileSync(patterns_dir + '/00-test/07-mixed-params.mustache', 'utf8');
|
471 | 464 | mixedPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(mixedPattern);
|
472 |
| - mixedPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(mixedPattern); |
| 465 | + mixedPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(mixedPattern); |
473 | 466 |
|
474 |
| - pl.patterns.push(atomPattern); |
475 |
| - pl.patterns.push(mixedPattern); |
| 467 | + pattern_assembler.addPattern(atomPattern, pl); |
| 468 | + pattern_assembler.addPattern(mixedPattern, pl); |
476 | 469 |
|
477 | 470 | //act
|
478 | 471 | pattern_assembler.process_pattern_recursive('test/files/_patterns/00-test/07-mixed-params.mustache', pl, {});
|
|
500 | 493 | pl.data.link = {};
|
501 | 494 | pl.config.debug = false;
|
502 | 495 | pl.patterns = [];
|
| 496 | + pl.partials = {}; |
503 | 497 |
|
504 | 498 | var atomPattern = new object_factory.oPattern('test/files/_patterns/00-test/03-styled-atom.mustache', '00-test', '03-styled-atom.mustache');
|
505 | 499 | atomPattern.template = fs.readFileSync(patterns_dir + '/00-test/03-styled-atom.mustache', 'utf8');
|
506 | 500 | atomPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(atomPattern);
|
507 |
| - atomPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(atomPattern); |
| 501 | + atomPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(atomPattern); |
508 | 502 |
|
509 | 503 | var bookendPattern = new object_factory.oPattern('test/files/_patterns/00-test/08-bookend-params.mustache', '00-test', '08-bookend-params.mustache');
|
510 | 504 | bookendPattern.template = fs.readFileSync(patterns_dir + '/00-test/08-bookend-params.mustache', 'utf8');
|
511 | 505 | bookendPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(bookendPattern);
|
512 |
| - bookendPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(bookendPattern); |
| 506 | + bookendPattern.parameteredPartials = pattern_assembler.find_pattern_partials_with_parameters(bookendPattern); |
513 | 507 |
|
514 |
| - pl.patterns.push(atomPattern); |
515 |
| - pl.patterns.push(bookendPattern); |
| 508 | + pattern_assembler.addPattern(atomPattern, pl); |
| 509 | + pattern_assembler.addPattern(bookendPattern, pl); |
516 | 510 |
|
517 | 511 | //act
|
518 | 512 | pattern_assembler.process_pattern_recursive('test/files/_patterns/00-test/08-bookend-params.mustache', pl, {});
|
|
720 | 714 | //assert
|
721 | 715 | test.equals(result, patternlab.patterns[1]);
|
722 | 716 | test.done();
|
| 717 | + }, |
| 718 | + 'addPattern - adds pattern extended template to patternlab partial object' : function(test){ |
| 719 | + //arrange |
| 720 | + var pattern_assembler = new pa(); |
| 721 | + var patternlab = {}; |
| 722 | + patternlab.patterns = []; |
| 723 | + patternlab.partials = {}; |
| 724 | + patternlab.data = {link: {}}; |
| 725 | + |
| 726 | + var pattern = new object_factory.oPattern('test/files/_patterns/00-test/01-bar.mustache', '00-test', '01-bar.mustache'); |
| 727 | + pattern.extendedTemplate = 'barExtended'; |
| 728 | + pattern.template = 'bar'; |
| 729 | + |
| 730 | + //act |
| 731 | + pattern_assembler.addPattern(pattern, patternlab); |
| 732 | + |
| 733 | + //assert |
| 734 | + test.equals(patternlab.patterns.length, 1); |
| 735 | + test.equals(patternlab.partials['test-bar'] != undefined, true); |
| 736 | + test.equals(patternlab.partials['test-bar'], 'barExtended'); |
| 737 | + test.done(); |
| 738 | + }, |
| 739 | + 'addPattern - adds pattern template to patternlab partial object if extendedtemplate does not exist yet' : function(test){ |
| 740 | + //arrange |
| 741 | + var pattern_assembler = new pa(); |
| 742 | + var patternlab = {}; |
| 743 | + patternlab.patterns = []; |
| 744 | + patternlab.partials = {}; |
| 745 | + patternlab.data = {link: {}}; |
| 746 | + |
| 747 | + var pattern = new object_factory.oPattern('test/files/_patterns/00-test/01-bar.mustache', '00-test', '01-bar.mustache'); |
| 748 | + pattern.extendedTemplate = undefined; |
| 749 | + pattern.template = 'bar'; |
| 750 | + |
| 751 | + //act |
| 752 | + pattern_assembler.addPattern(pattern, patternlab); |
| 753 | + |
| 754 | + //assert |
| 755 | + test.equals(patternlab.patterns.length, 1); |
| 756 | + test.equals(patternlab.partials['test-bar'] != undefined, true); |
| 757 | + test.equals(patternlab.partials['test-bar'], 'bar'); |
| 758 | + test.done(); |
723 | 759 | }
|
724 | 760 | };
|
725 | 761 | }());
|
0 commit comments