[js] fix test to use a stable ordering for test comparisons
@@ -339,14 +339,20 @@ describe('io', function() {
});
describe('walkDir', function() {
- it('walk directory', function() {
- return io.tmpDir().then(dir => {
+ it('walk directory', async function() {
+ let dir = await io.tmpDir();
+
fs.writeFileSync(path.join(dir, 'file1'), 'hello');
fs.mkdirSync(path.join(dir, 'sub'));
fs.mkdirSync(path.join(dir, 'sub/folder'));
fs.writeFileSync(path.join(dir, 'sub/folder/file2'), 'goodbye');
- return io.walkDir(dir).then(seen => {
+ let seen = await io.walkDir(dir);
+ seen.sort((a, b) => {
+ if (a.path < b.path) return -1;
+ if (a.path > b.path) return 1;
+ return 0;
+ });
assert.deepStrictEqual(
seen,
[{path: 'file1', dir: false},
@@ -354,7 +360,5 @@ describe('io', function() {
{path: path.join('sub', 'folder'), dir: true},
{path: path.join('sub', 'folder', 'file2'), dir: false}]);
});
- });
- });
})
});
