Skip to content

Commit 07b3f02

Browse files
committed
fix(pseudopattern)hunter): Add failing test
1 parent fca4d03 commit 07b3f02

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"message": "baseMessage"
3+
}

test/pseudopattern_hunter_tests.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ tap.test('pseudpattern found and added as a pattern', function (test) {
4646
//arrange
4747
var pl = stubPatternlab();
4848

49-
var atomPattern = new Pattern('00-test/03-styled-atom.mustache');
50-
atomPattern.template = fs.readFileSync(patterns_dir + '00-test/03-styled-atom.mustache', 'utf8');
51-
atomPattern.extendedTemplate = atomPattern.template;
52-
atomPattern.stylePartials = pattern_assembler.find_pattern_partials_with_style_modifiers(atomPattern);
53-
49+
var atomPattern = pattern_assembler.load_pattern_iterative('00-test/03-styled-atom.mustache', pl);
5450
pattern_assembler.addPattern(atomPattern, pl);
5551

5652
//act
@@ -59,12 +55,27 @@ tap.test('pseudpattern found and added as a pattern', function (test) {
5955
//assert
6056
test.equals(patternCountBefore + 1, pl.patterns.length);
6157
test.equals(pl.patterns[1].patternPartial, 'test-styled-atom-alt');
62-
test.equals(pl.patterns[1].extendedTemplate.replace(/\s\s+/g, ' ').replace(/\n/g, ' ').trim(), '<span class="test_base {{styleModifier}}"> {{message}} </span>');
6358
test.equals(JSON.stringify(pl.patterns[1].jsonFileData), JSON.stringify({"message": "alternateMessage"}));
6459
test.equals(pl.patterns[1].patternLink, '00-test-03-styled-atom-alt' + path.sep + '00-test-03-styled-atom-alt.html');
6560
});
6661
});
6762

63+
tap.test('pseudpattern does not pollute base pattern data', function (test) {
64+
//arrange
65+
var pl = stubPatternlab();
66+
67+
var atomPattern = pattern_assembler.load_pattern_iterative('00-test/03-styled-atom.mustache', pl);
68+
pattern_assembler.addPattern(atomPattern, pl);
69+
70+
//act
71+
var patternCountBefore = pl.patterns.length;
72+
return pph.find_pseudopatterns(atomPattern, pl).then(() => {
73+
//assert
74+
test.equals(pl.patterns[0].patternPartial, 'test-styled-atom');
75+
test.equals(JSON.stringify(pl.patterns[0].jsonFileData), JSON.stringify({"message": "baseMessage"}));
76+
});
77+
});
78+
6879
tap.test('pseudpattern variant includes stylePartials and parameteredPartials', function (test) {
6980
//arrange
7081
var pl = stubPatternlab();

0 commit comments

Comments
 (0)