File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -1941,8 +1941,18 @@ exports.defineAutoTests = function () {
1941
1941
directoryReader . readEntries ( function successRead ( entries ) {
1942
1942
expect ( entries . length ) . toBe ( 2 ) ;
1943
1943
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 ) ;
1946
1956
}
1947
1957
deleteEntry ( dstDir , done ) ;
1948
1958
} , failed . bind ( null , done , 'Error getting entries from: ' + transferredDirectory ) ) ;
You can’t perform that action at this time.
0 commit comments