Skip to content

Commit 12ccbd7

Browse files
committed
fix(event emission): Commit failing test
Proves watches are not being registered
1 parent bf4e0e8 commit 12ccbd7

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/watchPatternLabFiles_tests.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
'use strict';
2+
3+
const _ = require('lodash');
4+
const tap = require('tap');
5+
const rewire = require('rewire');
6+
const path = require('path');
7+
8+
const util = require('./util/test_utils.js');
9+
const watchPatternLabFiles = rewire('../core/lib/watchPatternLabFiles');
10+
11+
const patterns_dir = './test/files/_patterns';
12+
13+
tap.test(
14+
'watchPatternLabFiles - adds watcher to patternlab.watchers for given patternWatchPath',
15+
test => {
16+
const pl = util.fakePatternLab(patterns_dir, {
17+
watchers: [],
18+
engines: {},
19+
});
20+
21+
pl.engines.getSupportedFileExtensions = () => {
22+
return ['.mustache'];
23+
};
24+
25+
watchPatternLabFiles(
26+
pl,
27+
{
28+
source: {
29+
data: '_data',
30+
meta: '_meta',
31+
patterns: 'patterns',
32+
},
33+
},
34+
'/foo',
35+
true
36+
);
37+
38+
// should have two for _data and _meta
39+
// should have five for '.json', '.yml', '.yaml', '.md' and '.mustache'
40+
test.equals(Object.keys(pl.watchers).length, 7);
41+
42+
test.end();
43+
}
44+
);

0 commit comments

Comments
 (0)