Skip to content

Commit 83509fb

Browse files
took the liberty to adjust tests for third level subdirectories.
Why Pattern.info.hasDir exists and why Pattern.getDirLevel removes the last folder when this is true does not make sense to me. I'm guessing this is for a currently not functioning workaround to support a third sublevel if the folder and pattern name match.
1 parent 6a306ce commit 83509fb

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

packages/core/src/lib/object_factory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const Pattern = function(relPath, data, patternlab) {
3636
this.fileName = pathObj.name; // '00-colors'
3737
this.subdir = pathObj.dir; // '00-atoms/00-global'
3838
if ((this.subdir.match(/\w(?=\\)|\w(?=\/)/g) || []).length > 1) {
39-
this.subdir = this.subdir.split(/\/|\\/, 2).join(path.sep); // '00-atoms/03-controls/00-button' -> '00-atoms/00-global'
39+
this.subdir = this.subdir.split(/\/|\\/, 2).join(path.sep); // '00-atoms/03-controls/00-button' -> '00-atoms/03-controls'
4040
}
4141
this.fileExtension = pathObj.ext; // '.mustache'
4242

packages/core/test/object_factory_tests.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ tap.test(
7979
path.sep +
8080
'colors.mustache'
8181
);
82-
test.equals(p.name, '00-atoms-00-global-00-colors');
82+
test.equals(p.name, '00-atoms-00-global');
8383
test.equals(
8484
p.subdir,
85-
'00-atoms' + path.sep + '00-global' + path.sep + '00-colors'
85+
'00-atoms' + path.sep + '00-global'
8686
);
8787
test.equals(p.fileName, 'colors');
8888
test.equals(p.fileExtension, '.mustache');
@@ -91,12 +91,12 @@ tap.test(
9191
test.equals(p.patternName, 'Colors');
9292
test.equals(
9393
p.getPatternLink(pl),
94-
'00-atoms-00-global-00-colors' +
94+
'00-atoms-00-global' +
9595
path.sep +
96-
'00-atoms-00-global-00-colors.rendered.html'
96+
'00-atoms-00-global.rendered.html'
9797
);
9898
test.equals(p.patternGroup, 'atoms');
99-
test.equals(p.patternSubGroup, 'global');
99+
test.equals(p.patternSubGroup, 'atoms'); //because of p.info.hasDir
100100
test.equals(p.flatPatternPath, '00-atoms-00-global');
101101
test.equals(p.patternPartial, 'atoms-colors');
102102
test.equals(p.template, '');
@@ -111,15 +111,15 @@ tap.test(
111111
);
112112

113113
tap.test('test Pattern name for variants correctly initialzed', function(test) {
114-
var p1 = new Pattern('00-atoms/00-global/00-colors/colors~variant.mustache', {
114+
var p1 = new Pattern('00-atoms/00-global/colors~variant.mustache', {
115115
d: 123,
116116
});
117117
var p2 = new Pattern(
118-
'00-atoms/00-global/00-colors/colors~variant-minus.json',
118+
'00-atoms/00-global/colors~variant-minus.json',
119119
{ d: 123 }
120120
);
121-
test.equals(p1.name, '00-atoms-00-global-00-colors-variant');
122-
test.equals(p2.name, '00-atoms-00-global-00-colors-variant-minus');
121+
test.equals(p1.name, '00-atoms-00-global-colors-variant');
122+
test.equals(p2.name, '00-atoms-00-global-colors-variant-minus');
123123
test.end();
124124
});
125125

@@ -205,7 +205,7 @@ tap.test(
205205
{ d: 123 }
206206
);
207207
test.equals(p.getDirLevel(0, { hasDir: true, dirLevel: 3 }), '00-atoms');
208-
test.equals(p.getDirLevel(1, { hasDir: true, dirLevel: 3 }), '00-global');
208+
test.equals(p.getDirLevel(1, { hasDir: true, dirLevel: 3 }), '00-atoms');
209209
test.equals(p.getDirLevel(3, { hasDir: true, dirLevel: 3 }), '');
210210
var p = new Pattern('00-atoms/00-colors-alt/colors-alt.mustache', {
211211
d: 123,

0 commit comments

Comments
 (0)