|
2 | 2 | "use strict";
|
3 | 3 |
|
4 | 4 | var lih = require('../builder/list_item_hunter');
|
| 5 | + var pa = require('../builder/pattern_assembler'); |
| 6 | + var object_factory = require('../builder/object_factory'); |
5 | 7 |
|
6 | 8 | exports['list_item_hunter'] = {
|
7 | 9 | 'process_list_item_partials finds and outputs basic repeating blocks' : function(test){
|
|
396 | 398 | //assert
|
397 | 399 | test.equals(currentPattern.extendedTemplate, "One" );
|
398 | 400 |
|
| 401 | + test.done(); |
| 402 | + }, |
| 403 | + |
| 404 | + 'process_list_item_partials - correctly ignores bookended partials without a style modifier when the same partial has a style modifier between' : function(test){ |
| 405 | + //arrange |
| 406 | + var fs = require('fs-extra'); |
| 407 | + var pattern_assembler = new pa(); |
| 408 | + var list_item_hunter = new lih(); |
| 409 | + var patterns_dir = './test/files/_patterns'; |
| 410 | + |
| 411 | + var pl = {}; |
| 412 | + pl.config = {}; |
| 413 | + pl.data = {}; |
| 414 | + pl.data.link = {}; |
| 415 | + pl.config.debug = false; |
| 416 | + pl.patterns = []; |
| 417 | + pl.config.patterns = { source: patterns_dir}; |
| 418 | + pl.listitems = { |
| 419 | + "1": [ |
| 420 | + { |
| 421 | + "message": "Foo" |
| 422 | + } |
| 423 | + ], |
| 424 | + "2": [ |
| 425 | + { |
| 426 | + "message": "Foo" |
| 427 | + }, |
| 428 | + { |
| 429 | + "message": "Bar" |
| 430 | + } |
| 431 | + ] |
| 432 | + }; |
| 433 | + |
| 434 | + var atomPattern = new object_factory.oPattern('test/files/_patterns/00-test/03-styled-atom.mustache', '00-test', '03-styled-atom.mustache'); |
| 435 | + atomPattern.template = fs.readFileSync(patterns_dir + '/00-test/03-styled-atom.mustache', 'utf8'); |
| 436 | + atomPattern.extendedTemplate = atomPattern.template; |
| 437 | + atomPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(atomPattern); |
| 438 | + |
| 439 | + var bookendPattern = new object_factory.oPattern('test/files/_patterns/00-test/11-bookend-listitem.mustache', '00-test', '11-bookend-listitem.mustache'); |
| 440 | + bookendPattern.template = fs.readFileSync(patterns_dir + '/00-test/11-bookend-listitem.mustache', 'utf8'); |
| 441 | + bookendPattern.extendedTemplate = bookendPattern.template; |
| 442 | + bookendPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(bookendPattern); |
| 443 | + |
| 444 | + pl.patterns.push(atomPattern); |
| 445 | + pl.patterns.push(bookendPattern); |
| 446 | + |
| 447 | + //act |
| 448 | + list_item_hunter.process_list_item_partials(bookendPattern, pl); |
| 449 | + |
| 450 | + //assert. here we expect {{styleModifier}} to be replaced with an empty string or the styleModifier value from the found partial with the :styleModifier |
| 451 | + 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>'; |
| 452 | + test.equals(bookendPattern.extendedTemplate.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), expectedValue.trim()); |
399 | 453 | test.done();
|
400 | 454 | }
|
401 | 455 |
|
|
0 commit comments