dpogue commented on code in PR #643:
URL:
https://github.com/apache/cordova-plugin-file/pull/643#discussion_r1825357251
##########
tests/tests.js:
##########
@@ -1941,8 +1941,18 @@ exports.defineAutoTests = function () {
directoryReader.readEntries(function
successRead (entries) {
expect(entries.length).toBe(2);
if (!isChrome) {
-
expect(entries[0].name).toBe(srcDirNestedFirst);
-
expect(entries[1].name).toBe(srcDirNestedSecond);
+ // Directory read order is
undefined on some platforms, therefore we cannot assume order
+ // So we will start with an
expected list and iterate over the entries and test to see if they
+ // are in our expectation list.
When found we will remove them. At the end, our expectation list
+ // should be empty.
+ const expected =
[srcDirNestedFirst, srcDirNestedSecond];
+ for (let i = 0; i <
entries.length; i++) {
+ const index =
expected.indexOf(entries[i].name);
+
expect(index).toBeGreaterThan(-1);
+ expected.splice(index, 1);
+ }
+
+ expect(expected.length).toBe(0);
Review Comment:
Would `expect(entries).toEqual(jasmine.arrayWithExactContents(expected))`
work? Supposedly that doesn't care about order as long as the contents are the
same
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]