Skip to content

Commit

Permalink
[js] fix test to use a stable ordering for test comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyba committed Jun 6, 2019
1 parent 488eecc commit 49dc495
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions javascript/node/selenium-webdriver/test/io/io_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,22 +339,26 @@ describe('io', function() {
});

describe('walkDir', function() {
it('walk directory', function() {
return io.tmpDir().then(dir => {
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 => {
assert.deepStrictEqual(
seen,
[{path: 'file1', dir: false},
{path: 'sub', dir: true},
{path: path.join('sub', 'folder'), dir: true},
{path: path.join('sub', 'folder', 'file2'), dir: false}]);
});
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');

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},
{path: 'sub', dir: true},
{path: path.join('sub', 'folder'), dir: true},
{path: path.join('sub', 'folder', 'file2'), dir: false}]);
});
})
});

1 comment on commit 49dc495

@mmotahar
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this section. Is doesn't seem to solve stable ordering issue for test comparisons ?

Please sign in to comment.