Skip to content

Commit 30f3457

Browse files
committed
fix(test): file.spec.131 moveTo may fail due to read order assumption
1 parent 17155ed commit 30f3457

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tests/tests.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,8 +1941,18 @@ exports.defineAutoTests = function () {
19411941
directoryReader.readEntries(function successRead (entries) {
19421942
expect(entries.length).toBe(2);
19431943
if (!isChrome) {
1944-
expect(entries[0].name).toBe(srcDirNestedFirst);
1945-
expect(entries[1].name).toBe(srcDirNestedSecond);
1944+
// Directory read order is undefined on some platforms, therefore we cannot assume order
1945+
// So we will start with an expected list and iterate over the entries and test to see if they
1946+
// are in our expectation list. When found we will remove them. At the end, our expectation list
1947+
// should be empty.
1948+
const expected = [srcDirNestedFirst, srcDirNestedSecond];
1949+
for (let i = 0; i < entries.length; i++) {
1950+
const index = expected.indexOf(entries[i].name);
1951+
expect(index).toBeGreaterThan(-1);
1952+
expected.splice(index, 1);
1953+
}
1954+
1955+
expect(expected.length).toBe(0);
19461956
}
19471957
deleteEntry(dstDir, done);
19481958
}, failed.bind(null, done, 'Error getting entries from: ' + transferredDirectory));

0 commit comments

Comments
 (0)