Skip to content

Commit 2c6db20

Browse files
committed
fix(unit tests): Fix test
1 parent 9371818 commit 2c6db20

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

core/lib/decompose.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function expandPartials(foundPatternPartials, patternlab, currentPattern) {
4141
}
4242

4343
//recurse through nested partials to fill out this extended template.
44-
processRecursive(partialPath, patternlab).then(() => { //eslint-disable-line no-loop-func
44+
return processRecursive(partialPath, patternlab).then(() => { //eslint-disable-line no-loop-func
4545
//complete assembly of extended template
4646
//create a copy of the partial so as to not pollute it after the getPartial call.
4747
var partialPattern = getPartial(partial, patternlab);
@@ -55,6 +55,7 @@ function expandPartials(foundPatternPartials, patternlab, currentPattern) {
5555
//this is what we came here for
5656
logger.debug(`within ${currentPattern.patternPartial}, replacing extendedTemplate partial ${foundPartial} with ${cleanPartialPattern.patternPartial}'s extededTemplate`);
5757
currentPattern.extendedTemplate = currentPattern.extendedTemplate.replace(foundPartial, cleanPartialPattern.extendedTemplate);
58+
return Promise.resolve();
5859
});
5960
});
6061
}).catch(reason => {

core/lib/processRecursive.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module.exports = function (file, patternlab) {
2323
//call our helper method to actually unravel the pattern with any partials
2424
return decompose(currentPattern, patternlab)
2525
.catch(reason => {
26+
console.log(reason)
2627
logger.error(reason);
2728
});
2829
};

test/processRecursive_tests.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const buildListItems = require('../core/lib/buildListItems');
88
const pa = require('../core/lib/pattern_assembler');
99
const pattern_assembler = new pa();
1010
const engineLoader = require('../core/lib/pattern_engines');
11+
const getPartial = require('../core/lib/get');
1112
const processRecursive = require('../core/lib/processRecursive');
1213
const processIterative = require('../core/lib/processIterative');
1314

@@ -237,28 +238,37 @@ tap.test('processRecursive - ensure deep-nesting works', function (test) {
237238
var p2 = processIterative(templatePattern, patternlab);
238239
var p3 = processIterative(pagesPattern, patternlab);
239240

240-
Promise.all([p1, p2, p3]).then(() => {
241+
return Promise.all([
242+
p1,
243+
p2,
244+
p3,
245+
processRecursive(atomPath, patternlab),
246+
processRecursive(templatePath, patternlab),
247+
processRecursive(pagesPath, patternlab)
248+
]).then(() => {
241249
//act
242-
processRecursive(pagesPath, patternlab).then(() => {
250+
return test.test('processRecursive - ensure deep-nesting works2', function (tt) {
243251
//assert
244252
const expectedCleanValue = 'bar';
245253
const expectedSetValue = 'bar';
246254

247255
//this is the "atom" - it should remain unchanged
248-
test.equals(util.sanitized(atomPattern.template), expectedCleanValue);
249-
test.equals(util.sanitized(atomPattern.extendedTemplate), expectedCleanValue);
256+
tt.equals(util.sanitized(atomPattern.template), expectedCleanValue);
257+
tt.equals(util.sanitized(atomPattern.extendedTemplate), expectedCleanValue);
250258

251259
//this is the "template pattern" - it should have an updated extendedTemplate but an unchanged template
252-
test.equals(util.sanitized(templatePattern.template), '{{> test-bar }}');
253-
test.equals(util.sanitized(templatePattern.extendedTemplate), expectedSetValue);
260+
tt.equals(util.sanitized(templatePattern.template), '{{> test-bar }}');
261+
tt.equals(util.sanitized(templatePattern.extendedTemplate), expectedSetValue);
254262

255263
//this is the "pages pattern" - it should have an updated extendedTemplate equal to the template pattern but an unchanged template
256-
test.equals(util.sanitized(pagesPattern.template), '{{> test-foo }}');
257-
test.equals(util.sanitized(pagesPattern.extendedTemplate), expectedSetValue);
264+
tt.equals(util.sanitized(pagesPattern.template), '{{> test-foo }}');
265+
tt.equals(util.sanitized(pagesPattern.extendedTemplate), expectedSetValue);
266+
tt.end();
258267
test.end();
259-
}).catch(test.threw);
260-
}).catch(test.threw);
261-
});
268+
});
269+
270+
})
271+
}).catch(tap.threw);
262272

263273
tap.test('processRecursive - 685 ensure listitems data is used', function (test) {
264274
//arrange

0 commit comments

Comments
 (0)