Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions tests/tests.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

This line has a non-visible BOM (U+FEFF) -- can you strip that out (probably by saving as plain text, rather than "UTF-8 with BOM)

*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -18,6 +18,8 @@
*
*/
exports.defineAutoTests = function () {
var isWindows = (cordova.platformId == "windows") || (navigator.appVersion.indexOf("MSAppHost/1.0") !== -1);

describe('File API', function () {
// Adding a Jasmine helper matcher, to report errors when comparing to FileError better.
var fileErrorMap = {
Expand Down Expand Up @@ -2674,7 +2676,7 @@ exports.defineAutoTests = function () {
}, function (fileEntry) {
expect(fileEntry).toBeDefined();
expect(fileEntry.name).toBe(fileName);
expect(fileEntry.fullPath).toCanonicallyMatch('/' + fileName);
expect(fileEntry.fullPath).toCanonicallyMatch(root.fullPath +'/' + fileName);
// cleanup
deleteEntry(fileName);
done();
Expand Down Expand Up @@ -2722,14 +2724,19 @@ exports.defineAutoTests = function () {
var pathExpect = cordova.platformId === 'windowsphone' ? "//nativ" : "file://";
it("file.spec.114 fileEntry should have a toNativeURL method", function (done) {
var fileName = "native.file.uri";
if (isWindows) {
var rootPath = root.fullPath;
pathExpect = rootPath.substr(0, rootPath.indexOf(":"));
}
// create a new file entry
createFile(fileName, function (entry) {
expect(entry.toNativeURL).toBeDefined();
expect(entry.name).toCanonicallyMatch(fileName);
expect(typeof entry.toNativeURL).toBe('function');
var nativeURL = entry.toNativeURL();
var indexOfRoot = isWindows ? rootPath.indexOf(":") : 7;
expect(typeof nativeURL).toBe("string");
expect(nativeURL.substring(0, 7)).toEqual(pathExpect);
expect(nativeURL.substring(0, indexOfRoot)).toEqual(pathExpect);
expect(nativeURL.substring(nativeURL.length - fileName.length)).toEqual(fileName);
// cleanup
deleteEntry(fileName);
Expand All @@ -2746,8 +2753,9 @@ exports.defineAutoTests = function () {
expect(entries[0].toNativeURL).toBeDefined();
expect(typeof entries[0].toNativeURL).toBe('function');
var nativeURL = entries[0].toNativeURL();
var indexOfRoot = (isWindows) ? nativeURL.indexOf(":") : 7;
expect(typeof nativeURL).toBe("string");
expect(nativeURL.substring(0, 7)).toEqual(pathExpect);
expect(nativeURL.substring(0, indexOfRoot)).toEqual(pathExpect);
expect(nativeURL.substring(nativeURL.length - fileName.length)).toEqual(fileName);
// cleanup
directory.removeRecursively(null, null);
Expand All @@ -2774,8 +2782,9 @@ exports.defineAutoTests = function () {
expect(entry.name).toCanonicallyMatch(fileName);
expect(typeof entry.toNativeURL).toBe('function');
var nativeURL = entry.toNativeURL();
var indexOfRoot = (isWindows) ? nativeURL.indexOf(":") : 7;
expect(typeof nativeURL).toBe("string");
expect(nativeURL.substring(0, 7)).toEqual(pathExpect);
expect(nativeURL.substring(0, indexOfRoot)).toEqual(pathExpect);
expect(nativeURL.substring(nativeURL.length - fileName.length)).toEqual(fileName);
// cleanup
deleteEntry(fileName);
Expand Down Expand Up @@ -2821,7 +2830,7 @@ exports.defineAutoTests = function () {
// create a new file entry
createFile(fileName, function (entry) {
resolveLocalFileSystemURL(entry.toNativeURL(), function (fileEntry) {
expect(fileEntry.fullPath).toCanonicallyMatch("/" + fileName);
expect(fileEntry.fullPath).toCanonicallyMatch(root.fullPath + "/" + fileName);
// cleanup
deleteEntry(fileName);
done();
Expand All @@ -2835,7 +2844,7 @@ exports.defineAutoTests = function () {
var url = entry.toNativeURL();
url = url.replace("///", "//localhost/");
resolveLocalFileSystemURL(url, function (fileEntry) {
expect(fileEntry.fullPath).toCanonicallyMatch("/" + fileName);
expect(fileEntry.fullPath).toCanonicallyMatch(root.fullPath + "/" + fileName);
// cleanup
deleteEntry(fileName);
done();
Expand All @@ -2849,7 +2858,7 @@ exports.defineAutoTests = function () {
var url = entry.toNativeURL();
url = url + "?test/test";
resolveLocalFileSystemURL(url, function (fileEntry) {
expect(fileEntry.fullPath).toCanonicallyMatch("/" + fileName);
expect(fileEntry.fullPath).toCanonicallyMatch(root.fullPath + "/" + fileName);
// cleanup
deleteEntry(fileName);
done();
Expand All @@ -2863,7 +2872,7 @@ exports.defineAutoTests = function () {
var url = entry.toNativeURL();
url = url.replace("///", "//localhost/") + "?test/test";
resolveLocalFileSystemURL(url, function (fileEntry) {
expect(fileEntry.fullPath).toCanonicallyMatch("/" + fileName);
expect(fileEntry.fullPath).toCanonicallyMatch(root.fullPath + "/" + fileName);
// cleanup
deleteEntry(fileName);
done();
Expand Down