Skip to content

Commit b157787

Browse files
committed
[CB-7417][File tests] added proper matcher to compare fullPath property
Specs : 111, 112 & 121-124, were using [toBe, toEqual] to compare a fullPath property from an Entry. The right matcher to use is toCanonicallyMatch, that it makes a fair and right comparison across platforms. In addition, special case to compare Windows Phone entries, was removed.
1 parent 99ade61 commit b157787

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

tests/tests.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,7 @@ exports.defineAutoTests = function () {
249249
expect(fileEntry).toBeDefined();
250250
expect(fileEntry.name).toCanonicallyMatch(fileName);
251251
expect(fileEntry.toURL()).not.toMatch(/^cdvfile:/, 'should not use cdvfile URL');
252-
if (cordova.platformId === 'windowsphone') {
253-
expect(fileEntry.toURL()).not.toMatch(/\/$/, 'URL end with a slash');
254-
} else {
255-
expect(fileEntry.toURL()).toMatch(/\/$/, 'URL end with a slash');
256-
}
252+
expect(fileEntry.toURL()).toMatch(/\/$/, 'URL end with a slash');
257253
// cleanup
258254
deleteEntry(fileName);
259255
done();
@@ -750,8 +746,8 @@ exports.defineAutoTests = function () {
750746
// remove root file system
751747
root.removeRecursively(succeed.bind(null, done, 'root.removeRecursively - Unexpected success callback, root cannot be removed'), remove);
752748
});
753-
});
754-
describe('DirectoryReader interface', function () {
749+
});
750+
describe('DirectoryReader interface', function () {
755751
describe("readEntries", function () {
756752
it("file.spec.37 should read contents of existing directory", function (done) {
757753
var reader,
@@ -2684,7 +2680,7 @@ exports.defineAutoTests = function () {
26842680
}, function (fileEntry) {
26852681
expect(fileEntry).toBeDefined();
26862682
expect(fileEntry.name).toBe(fileName);
2687-
expect(fileEntry.fullPath).toBe('/' + fileName);
2683+
expect(fileEntry.fullPath).toCanonicallyMatch('/' + fileName);
26882684
// cleanup
26892685
deleteEntry(fileName);
26902686
done();
@@ -2703,7 +2699,7 @@ exports.defineAutoTests = function () {
27032699
}, function (fileEntry) {
27042700
expect(fileEntry).toBeDefined();
27052701
expect(fileEntry.name).toBe(fileName);
2706-
expect(fileEntry.fullPath).toBe('/' + fileName);
2702+
expect(fileEntry.fullPath).toCanonicallyMatch('/' + fileName);
27072703
// cleanup
27082704
deleteEntry(fileName);
27092705
deleteEntry(dirName);
@@ -2831,7 +2827,7 @@ exports.defineAutoTests = function () {
28312827
// create a new file entry
28322828
createFile(fileName, function (entry) {
28332829
resolveLocalFileSystemURL(entry.toNativeURL(), function (fileEntry) {
2834-
expect(fileEntry.fullPath).toEqual("/" + fileName);
2830+
expect(fileEntry.fullPath).toCanonicallyMatch("/" + fileName);
28352831
// cleanup
28362832
deleteEntry(fileName);
28372833
done();
@@ -2845,7 +2841,7 @@ exports.defineAutoTests = function () {
28452841
var url = entry.toNativeURL();
28462842
url = url.replace("///", "//localhost/");
28472843
resolveLocalFileSystemURL(url, function (fileEntry) {
2848-
expect(fileEntry.fullPath).toEqual("/" + fileName);
2844+
expect(fileEntry.fullPath).toCanonicallyMatch("/" + fileName);
28492845
// cleanup
28502846
deleteEntry(fileName);
28512847
done();
@@ -2859,7 +2855,7 @@ exports.defineAutoTests = function () {
28592855
var url = entry.toNativeURL();
28602856
url = url + "?test/test";
28612857
resolveLocalFileSystemURL(url, function (fileEntry) {
2862-
expect(fileEntry.fullPath).toEqual("/" + fileName);
2858+
expect(fileEntry.fullPath).toCanonicallyMatch("/" + fileName);
28632859
// cleanup
28642860
deleteEntry(fileName);
28652861
done();
@@ -2873,7 +2869,7 @@ exports.defineAutoTests = function () {
28732869
var url = entry.toNativeURL();
28742870
url = url.replace("///", "//localhost/") + "?test/test";
28752871
resolveLocalFileSystemURL(url, function (fileEntry) {
2876-
expect(fileEntry.fullPath).toEqual("/" + fileName);
2872+
expect(fileEntry.fullPath).toCanonicallyMatch("/" + fileName);
28772873
// cleanup
28782874
deleteEntry(fileName);
28792875
done();

0 commit comments

Comments
 (0)