Skip to content

Commit

Permalink
Make test pass on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanchuan committed Oct 22, 2020
1 parent 0d66a86 commit 2e42be3
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,26 @@ describe('watch for files', function() {
tree.newFile(newfile1);
tree.newFile(newfile2);
wait(function() {
// On windows it will report its parent directory along the the filename
// On windows it will report its parent directory along with the filename
// https://github.com/yuanchuan/node-watch/issues/79
if (is.windows()) {
assert.deepStrictEqual(
changes.sort(),
[
tree.getPath('home/a'),
tree.getPath('home/a'),
tree.getPath(newfile1),
tree.getPath(newfile2)
].sort()
// Make sure new files are deteced
assert.ok(
changes.includes(tree.getPath(newfile1)) &&
changes.includes(tree.getPath(newfile2))
);
// It should only include new files and its parent directory
// if there are more than 2 events
if (changes.length > 2) {
let accepts = [
tree.getPath(newfile1),
tree.getPath(newfile2),
tree.getPath('home/a')
];
changes.forEach(function(name) {
assert.ok(accepts.includes(name), name + " should not be included");
});
}
} else {
assert.deepStrictEqual(
changes,
Expand Down

0 comments on commit 2e42be3

Please sign in to comment.