mirror of https://github.com/vitalif/phantomjs
Fixing up indentation for our Jasmine test specs.
Just getting rid of an itch of mine.1.9
parent
12bb24f418
commit
7e7325c0f5
|
@ -1,9 +1,9 @@
|
||||||
describe("Basic Files API (read, write, remove, ...)", function() {
|
describe("Basic Files API (read, write, remove, ...)", function() {
|
||||||
var FILENAME = "temp-01.test",
|
var FILENAME = "temp-01.test",
|
||||||
FILENAME_COPY = FILENAME + ".copy",
|
FILENAME_COPY = FILENAME + ".copy",
|
||||||
FILENAME_MOVED = FILENAME + ".moved",
|
FILENAME_MOVED = FILENAME + ".moved",
|
||||||
FILENAME_EMPTY = FILENAME + ".empty",
|
FILENAME_EMPTY = FILENAME + ".empty",
|
||||||
FILENAME_ENC = FILENAME + ".enc",
|
FILENAME_ENC = FILENAME + ".enc",
|
||||||
FILENAME_BIN = FILENAME + ".bin",
|
FILENAME_BIN = FILENAME + ".bin",
|
||||||
ABSENT = "absent-01.test";
|
ABSENT = "absent-01.test";
|
||||||
|
|
||||||
|
@ -19,12 +19,12 @@ describe("Basic Files API (read, write, remove, ...)", function() {
|
||||||
expect(fs.exists(FILENAME)).toBeTruthy();
|
expect(fs.exists(FILENAME)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to create (touch) an empty file", function() {
|
it("should be able to create (touch) an empty file", function() {
|
||||||
expect(fs.exists(FILENAME_EMPTY)).toBeFalsy();
|
expect(fs.exists(FILENAME_EMPTY)).toBeFalsy();
|
||||||
fs.touch(FILENAME_EMPTY);
|
fs.touch(FILENAME_EMPTY);
|
||||||
expect(fs.exists(FILENAME_EMPTY)).toBeTruthy();
|
expect(fs.exists(FILENAME_EMPTY)).toBeTruthy();
|
||||||
expect(fs.size(FILENAME_EMPTY)).toEqual(0);
|
expect(fs.size(FILENAME_EMPTY)).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to read content from a file", function() {
|
it("should be able to read content from a file", function() {
|
||||||
var content = "";
|
var content = "";
|
||||||
|
@ -59,35 +59,35 @@ describe("Basic Files API (read, write, remove, ...)", function() {
|
||||||
expect(content).toEqual("hello\nworld\nasdf\n");
|
expect(content).toEqual("hello\nworld\nasdf\n");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to copy a file", function() {
|
it("should be able to copy a file", function() {
|
||||||
expect(fs.exists(FILENAME_COPY)).toBeFalsy();
|
expect(fs.exists(FILENAME_COPY)).toBeFalsy();
|
||||||
fs.copy(FILENAME, FILENAME_COPY);
|
fs.copy(FILENAME, FILENAME_COPY);
|
||||||
expect(fs.exists(FILENAME_COPY)).toBeTruthy();
|
expect(fs.exists(FILENAME_COPY)).toBeTruthy();
|
||||||
expect(fs.read(FILENAME)).toEqual(fs.read(FILENAME_COPY));
|
expect(fs.read(FILENAME)).toEqual(fs.read(FILENAME_COPY));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to move a file", function() {
|
it("should be able to move a file", function() {
|
||||||
expect(fs.exists(FILENAME)).toBeTruthy();
|
expect(fs.exists(FILENAME)).toBeTruthy();
|
||||||
var contentBeforeMove = fs.read(FILENAME);
|
var contentBeforeMove = fs.read(FILENAME);
|
||||||
fs.move(FILENAME, FILENAME_MOVED);
|
fs.move(FILENAME, FILENAME_MOVED);
|
||||||
expect(fs.exists(FILENAME)).toBeFalsy();
|
expect(fs.exists(FILENAME)).toBeFalsy();
|
||||||
expect(fs.exists(FILENAME_MOVED)).toBeTruthy();
|
expect(fs.exists(FILENAME_MOVED)).toBeTruthy();
|
||||||
expect(fs.read(FILENAME_MOVED)).toEqual(contentBeforeMove);
|
expect(fs.read(FILENAME_MOVED)).toEqual(contentBeforeMove);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to remove a (moved) file", function() {
|
it("should be able to remove a (moved) file", function() {
|
||||||
expect(fs.exists(FILENAME_MOVED)).toBeTruthy();
|
expect(fs.exists(FILENAME_MOVED)).toBeTruthy();
|
||||||
fs.remove(FILENAME_MOVED);
|
fs.remove(FILENAME_MOVED);
|
||||||
expect(fs.exists(FILENAME_MOVED)).toBeFalsy();
|
expect(fs.exists(FILENAME_MOVED)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to remove a (copied) file", function() {
|
it("should be able to remove a (copied) file", function() {
|
||||||
expect(fs.exists(FILENAME_COPY)).toBeTruthy();
|
expect(fs.exists(FILENAME_COPY)).toBeTruthy();
|
||||||
fs.remove(FILENAME_COPY);
|
fs.remove(FILENAME_COPY);
|
||||||
expect(fs.exists(FILENAME_COPY)).toBeFalsy();
|
expect(fs.exists(FILENAME_COPY)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to remove an empty file", function() {
|
it("should be able to remove an empty file", function() {
|
||||||
expect(fs.exists(FILENAME_EMPTY)).toBeTruthy();
|
expect(fs.exists(FILENAME_EMPTY)).toBeTruthy();
|
||||||
fs.remove(FILENAME_EMPTY);
|
fs.remove(FILENAME_EMPTY);
|
||||||
expect(fs.exists(FILENAME_EMPTY)).toBeFalsy();
|
expect(fs.exists(FILENAME_EMPTY)).toBeFalsy();
|
||||||
|
@ -99,27 +99,27 @@ describe("Basic Files API (read, write, remove, ...)", function() {
|
||||||
}).toThrow("Unable to open file '"+ ABSENT +"'");
|
}).toThrow("Unable to open file '"+ ABSENT +"'");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should throw an exception when trying to copy a non existing file", function() {
|
it("should throw an exception when trying to copy a non existing file", function() {
|
||||||
expect(function(){
|
expect(function(){
|
||||||
fs.copy(ABSENT, FILENAME_COPY);
|
fs.copy(ABSENT, FILENAME_COPY);
|
||||||
}).toThrow("Unable to copy file '" + ABSENT + "' at '" + FILENAME_COPY + "'");
|
}).toThrow("Unable to copy file '" + ABSENT + "' at '" + FILENAME_COPY + "'");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be read/write utf8 text by default", function() {
|
it("should be read/write utf8 text by default", function() {
|
||||||
var content, output = "ÄABCÖ";
|
var content, output = "ÄABCÖ";
|
||||||
try {
|
try {
|
||||||
var f = fs.open(FILENAME_ENC, "w");
|
var f = fs.open(FILENAME_ENC, "w");
|
||||||
f.write(output);
|
f.write(output);
|
||||||
f.close();
|
f.close();
|
||||||
|
|
||||||
f = fs.open(FILENAME_ENC, "r");
|
f = fs.open(FILENAME_ENC, "r");
|
||||||
content = f.read();
|
content = f.read();
|
||||||
f.close();
|
f.close();
|
||||||
|
|
||||||
fs.remove(FILENAME_ENC);
|
fs.remove(FILENAME_ENC);
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
expect(content).toEqual(output);
|
expect(content).toEqual(output);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be read/write binary data", function() {
|
it("should be read/write binary data", function() {
|
||||||
var content, output = String.fromCharCode(0, 1, 2, 3, 4, 5);
|
var content, output = String.fromCharCode(0, 1, 2, 3, 4, 5);
|
||||||
|
|
|
@ -9,15 +9,15 @@ describe("Attributes Files API", function() {
|
||||||
fs.size(ABSENT);
|
fs.size(ABSENT);
|
||||||
}).toThrow("Unable to read file '"+ ABSENT +"' size");
|
}).toThrow("Unable to read file '"+ ABSENT +"' size");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return a null Date object when trying to read the last modified date of a non existing file", function(){
|
it("should return a null Date object when trying to read the last modified date of a non existing file", function(){
|
||||||
expect(fs.lastModified(ABSENT)).toBeNull();
|
expect(fs.lastModified(ABSENT)).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create temporary file '"+ FILENAME +"' and writes some content in it", function(){
|
it("should create temporary file '"+ FILENAME +"' and writes some content in it", function(){
|
||||||
try{
|
try{
|
||||||
var f = fs.open(FILENAME, "w");
|
var f = fs.open(FILENAME, "w");
|
||||||
|
|
||||||
expect(f).toBeDefined();
|
expect(f).toBeDefined();
|
||||||
for (var i = 1; i <= CONTENT_MULTIPLIER; ++i) {
|
for (var i = 1; i <= CONTENT_MULTIPLIER; ++i) {
|
||||||
f.write(CONTENT);
|
f.write(CONTENT);
|
||||||
|
@ -25,11 +25,11 @@ describe("Attributes Files API", function() {
|
||||||
f.close();
|
f.close();
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to read the size of a temporary file '"+ FILENAME +"'", function() {
|
it("should be able to read the size of a temporary file '"+ FILENAME +"'", function() {
|
||||||
expect(fs.size(FILENAME)).toEqual(CONTENT.length * CONTENT_MULTIPLIER);
|
expect(fs.size(FILENAME)).toEqual(CONTENT.length * CONTENT_MULTIPLIER);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to read the Date on which a temporary file '"+ FILENAME +"' was last modified", function() {
|
it("should be able to read the Date on which a temporary file '"+ FILENAME +"' was last modified", function() {
|
||||||
var flm = fs.lastModified(FILENAME),
|
var flm = fs.lastModified(FILENAME),
|
||||||
now = new Date();
|
now = new Date();
|
||||||
|
@ -39,8 +39,8 @@ describe("Attributes Files API", function() {
|
||||||
expect(now.getFullYear()).toEqual(flm.getFullYear());
|
expect(now.getFullYear()).toEqual(flm.getFullYear());
|
||||||
expect(now.getMilliseconds()).toNotEqual(flm.getMilliseconds());
|
expect(now.getMilliseconds()).toNotEqual(flm.getMilliseconds());
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should remove temporary file '"+ FILENAME +"'", function(){
|
it("should remove temporary file '"+ FILENAME +"'", function(){
|
||||||
fs.remove(FILENAME);
|
fs.remove(FILENAME);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,137 +1,137 @@
|
||||||
describe("Files and Directories API", function() {
|
describe("Files and Directories API", function() {
|
||||||
var TEST_DIR = "testdir",
|
var TEST_DIR = "testdir",
|
||||||
TEST_FILE = "testfile",
|
TEST_FILE = "testfile",
|
||||||
START_CWD = fs.workingDirectory;
|
START_CWD = fs.workingDirectory;
|
||||||
|
|
||||||
it("should create a new temporary directory and change the Current Working Directory to it", function() {
|
it("should create a new temporary directory and change the Current Working Directory to it", function() {
|
||||||
expect(fs.makeDirectory(TEST_DIR)).toBeTruthy();
|
expect(fs.makeDirectory(TEST_DIR)).toBeTruthy();
|
||||||
expect(fs.changeWorkingDirectory(TEST_DIR)).toBeTruthy();
|
expect(fs.changeWorkingDirectory(TEST_DIR)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create a file in the Current Working Directory and check it's absolute path", function() {
|
it("should create a file in the Current Working Directory and check it's absolute path", function() {
|
||||||
fs.write(TEST_FILE, TEST_FILE, "w");
|
fs.write(TEST_FILE, TEST_FILE, "w");
|
||||||
var suffix = fs.join("", TEST_DIR, TEST_FILE),
|
var suffix = fs.join("", TEST_DIR, TEST_FILE),
|
||||||
abs = fs.absolute(".." + suffix),
|
abs = fs.absolute(".." + suffix),
|
||||||
lastIndex = abs.lastIndexOf(suffix);
|
lastIndex = abs.lastIndexOf(suffix);
|
||||||
expect(lastIndex).toNotEqual(-1);
|
expect(lastIndex).toNotEqual(-1);
|
||||||
expect(lastIndex + suffix.length === abs.length);
|
expect(lastIndex + suffix.length === abs.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return to previous Current Working Directory and remove temporary directory", function() {
|
it("should return to previous Current Working Directory and remove temporary directory", function() {
|
||||||
expect(fs.changeWorkingDirectory(START_CWD)).toBeTruthy();
|
expect(fs.changeWorkingDirectory(START_CWD)).toBeTruthy();
|
||||||
fs.removeTree(TEST_DIR);
|
fs.removeTree(TEST_DIR);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should copy Content of the '/test/' Directory in a temporary directory, compare with the original and then remove", function() {
|
it("should copy Content of the '/test/' Directory in a temporary directory, compare with the original and then remove", function() {
|
||||||
var phantomLibraryPathListingLength = fs.list(phantom.libraryPath).length;
|
var phantomLibraryPathListingLength = fs.list(phantom.libraryPath).length;
|
||||||
fs.copyTree(phantom.libraryPath, "/tmp/"+TEST_DIR);
|
fs.copyTree(phantom.libraryPath, "/tmp/"+TEST_DIR);
|
||||||
expect(phantomLibraryPathListingLength === fs.list("/tmp/"+TEST_DIR).length);
|
expect(phantomLibraryPathListingLength === fs.list("/tmp/"+TEST_DIR).length);
|
||||||
fs.removeTree("/tmp/"+TEST_DIR);
|
fs.removeTree("/tmp/"+TEST_DIR);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: test the actual functionality once we can create symlink.
|
// TODO: test the actual functionality once we can create symlink.
|
||||||
it("should have readLink function", function() {
|
it("should have readLink function", function() {
|
||||||
expect(typeof fs.readLink).toEqual('function');
|
expect(typeof fs.readLink).toEqual('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.removeTree(TEST_DIR);
|
fs.removeTree(TEST_DIR);
|
||||||
|
|
||||||
describe("fs.join(...)", function() {
|
describe("fs.join(...)", function() {
|
||||||
var parts, expected, actual;
|
var parts, expected, actual;
|
||||||
|
|
||||||
it("empty parts", function() {
|
it("empty parts", function() {
|
||||||
parts = [];
|
parts = [];
|
||||||
expected = ".";
|
expected = ".";
|
||||||
actual = fs.join.apply(null, parts);
|
actual = fs.join.apply(null, parts);
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("one part (empty string)", function() {
|
it("one part (empty string)", function() {
|
||||||
parts = [""];
|
parts = [""];
|
||||||
expected = ".";
|
expected = ".";
|
||||||
actual = fs.join.apply(null, parts);
|
actual = fs.join.apply(null, parts);
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("one part (array)", function() {
|
it("one part (array)", function() {
|
||||||
parts = [[], null];
|
parts = [[], null];
|
||||||
expected = ".";
|
expected = ".";
|
||||||
actual = fs.join.apply(null, parts);
|
actual = fs.join.apply(null, parts);
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("empty string and one part", function() {
|
it("empty string and one part", function() {
|
||||||
parts = ["", "a"];
|
parts = ["", "a"];
|
||||||
expected = "/a";
|
expected = "/a";
|
||||||
actual = fs.join.apply(null, parts);
|
actual = fs.join.apply(null, parts);
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("empty string and multiple parts", function() {
|
it("empty string and multiple parts", function() {
|
||||||
parts = ["", "a", "b", "c"];
|
parts = ["", "a", "b", "c"];
|
||||||
expected = "/a/b/c";
|
expected = "/a/b/c";
|
||||||
actual = fs.join.apply(null, parts);
|
actual = fs.join.apply(null, parts);
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("empty string and multiple parts with empty strings", function() {
|
it("empty string and multiple parts with empty strings", function() {
|
||||||
parts = ["", "a", "", "b", "", "c"];
|
parts = ["", "a", "", "b", "", "c"];
|
||||||
expected = "/a/b/c";
|
expected = "/a/b/c";
|
||||||
actual = fs.join.apply(null, parts);
|
actual = fs.join.apply(null, parts);
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("multiple parts", function() {
|
it("multiple parts", function() {
|
||||||
parts = ["a", "b", "c"];
|
parts = ["a", "b", "c"];
|
||||||
expected = "a/b/c";
|
expected = "a/b/c";
|
||||||
actual = fs.join.apply(null, parts);
|
actual = fs.join.apply(null, parts);
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("multiple parts with empty strings", function() {
|
it("multiple parts with empty strings", function() {
|
||||||
parts = ["a", "", "b", "", "c"];
|
parts = ["a", "", "b", "", "c"];
|
||||||
expected = "a/b/c";
|
expected = "a/b/c";
|
||||||
actual = fs.join.apply(null, parts);
|
actual = fs.join.apply(null, parts);
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("fs.split(path)", function() {
|
describe("fs.split(path)", function() {
|
||||||
var path, expected, actual;
|
var path, expected, actual;
|
||||||
|
|
||||||
it("should split absolute path with trailing separator", function() {
|
it("should split absolute path with trailing separator", function() {
|
||||||
path = fs.separator + "a" + fs.separator + "b" + fs.separator + "c" + fs.separator + "d" + fs.separator;
|
path = fs.separator + "a" + fs.separator + "b" + fs.separator + "c" + fs.separator + "d" + fs.separator;
|
||||||
actual = fs.split(path);
|
actual = fs.split(path);
|
||||||
expected = ["", "a", "b", "c", "d"];
|
expected = ["", "a", "b", "c", "d"];
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should split absolute path without trailing separator", function() {
|
it("should split absolute path without trailing separator", function() {
|
||||||
path = fs.separator + "a" + fs.separator + "b" + fs.separator + "c" + fs.separator + "d";
|
path = fs.separator + "a" + fs.separator + "b" + fs.separator + "c" + fs.separator + "d";
|
||||||
actual = fs.split(path);
|
actual = fs.split(path);
|
||||||
expected = ["", "a", "b", "c", "d"];
|
expected = ["", "a", "b", "c", "d"];
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should split non-absolute path with trailing separator", function() {
|
it("should split non-absolute path with trailing separator", function() {
|
||||||
path = "a" + fs.separator + "b" + fs.separator + "c" + fs.separator + "d" + fs.separator;
|
path = "a" + fs.separator + "b" + fs.separator + "c" + fs.separator + "d" + fs.separator;
|
||||||
actual = fs.split(path);
|
actual = fs.split(path);
|
||||||
expected = ["a", "b", "c", "d"];
|
expected = ["a", "b", "c", "d"];
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should split non-absolute path without trailing separator", function() {
|
it("should split non-absolute path without trailing separator", function() {
|
||||||
path = "a" + fs.separator + "b" + fs.separator + "c" + fs.separator + "d";
|
path = "a" + fs.separator + "b" + fs.separator + "c" + fs.separator + "d";
|
||||||
actual = fs.split(path);
|
actual = fs.split(path);
|
||||||
expected = ["a", "b", "c", "d"];
|
expected = ["a", "b", "c", "d"];
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should split path with consecutive separators", function() {
|
it("should split path with consecutive separators", function() {
|
||||||
path = "a" + fs.separator + fs.separator + fs.separator + "b" + fs.separator + "c" + fs.separator + fs.separator + "d" + fs.separator + fs.separator + fs.separator;
|
path = "a" + fs.separator + fs.separator + fs.separator + "b" + fs.separator + "c" + fs.separator + fs.separator + "d" + fs.separator + fs.separator + fs.separator;
|
||||||
expected = ["a", "b", "c", "d"];
|
expected = ["a", "b", "c", "d"];
|
||||||
actual = fs.split(path);
|
actual = fs.split(path);
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,70 +1,70 @@
|
||||||
describe("Tests Files API", function() {
|
describe("Tests Files API", function() {
|
||||||
var ABSENT_DIR = "absentdir04",
|
var ABSENT_DIR = "absentdir04",
|
||||||
ABSENT_FILE = "absentfile04",
|
ABSENT_FILE = "absentfile04",
|
||||||
TEST_DIR = "testdir04",
|
TEST_DIR = "testdir04",
|
||||||
TEST_FILE = "testfile04",
|
TEST_FILE = "testfile04",
|
||||||
TEST_FILE_PATH = fs.join(TEST_DIR, TEST_FILE),
|
TEST_FILE_PATH = fs.join(TEST_DIR, TEST_FILE),
|
||||||
TEST_CONTENT = "test content",
|
TEST_CONTENT = "test content",
|
||||||
START_CWD = null;
|
START_CWD = null;
|
||||||
|
|
||||||
it("should create some temporary file and directory", function(){
|
it("should create some temporary file and directory", function(){
|
||||||
fs.makeDirectory(TEST_DIR);
|
fs.makeDirectory(TEST_DIR);
|
||||||
fs.write(TEST_FILE_PATH, TEST_CONTENT, "w");
|
fs.write(TEST_FILE_PATH, TEST_CONTENT, "w");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should confirm that test file and test dir exist, while the absent ones don't", function(){
|
it("should confirm that test file and test dir exist, while the absent ones don't", function(){
|
||||||
expect(fs.exists(TEST_FILE_PATH)).toBeTruthy();
|
expect(fs.exists(TEST_FILE_PATH)).toBeTruthy();
|
||||||
expect(fs.exists(TEST_DIR)).toBeTruthy();
|
expect(fs.exists(TEST_DIR)).toBeTruthy();
|
||||||
expect(fs.exists(ABSENT_FILE)).toBeFalsy();
|
expect(fs.exists(ABSENT_FILE)).toBeFalsy();
|
||||||
expect(fs.exists(ABSENT_DIR)).toBeFalsy();
|
expect(fs.exists(ABSENT_DIR)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should confirm that the temporary directory is infact a directory, while the absent one doesn't", function(){
|
it("should confirm that the temporary directory is infact a directory, while the absent one doesn't", function(){
|
||||||
expect(fs.isDirectory(TEST_DIR)).toBeTruthy();
|
expect(fs.isDirectory(TEST_DIR)).toBeTruthy();
|
||||||
expect(fs.isDirectory(ABSENT_DIR)).toBeFalsy();
|
expect(fs.isDirectory(ABSENT_DIR)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should confirm that the temporary file is infact a file, while the absent one doesn't", function(){
|
it("should confirm that the temporary file is infact a file, while the absent one doesn't", function(){
|
||||||
expect(fs.isFile(TEST_FILE_PATH)).toBeTruthy();
|
expect(fs.isFile(TEST_FILE_PATH)).toBeTruthy();
|
||||||
expect(fs.isFile(ABSENT_FILE)).toBeFalsy();
|
expect(fs.isFile(ABSENT_FILE)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should confirm that a relative path is not absolute, while an absolute one is", function(){
|
it("should confirm that a relative path is not absolute, while an absolute one is", function(){
|
||||||
var absPath = fs.absolute(TEST_FILE_PATH);
|
var absPath = fs.absolute(TEST_FILE_PATH);
|
||||||
|
|
||||||
expect(fs.isAbsolute(TEST_FILE_PATH)).toBeFalsy();
|
expect(fs.isAbsolute(TEST_FILE_PATH)).toBeFalsy();
|
||||||
expect(fs.isAbsolute(absPath)).toBeTruthy();
|
expect(fs.isAbsolute(absPath)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should confirm that temporary file is readable, writable and non-executable, while absent file is none of those", function(){
|
it("should confirm that temporary file is readable, writable and non-executable, while absent file is none of those", function(){
|
||||||
expect(fs.isReadable(TEST_FILE_PATH)).toBeTruthy();
|
expect(fs.isReadable(TEST_FILE_PATH)).toBeTruthy();
|
||||||
expect(fs.isWritable(TEST_FILE_PATH)).toBeTruthy();
|
expect(fs.isWritable(TEST_FILE_PATH)).toBeTruthy();
|
||||||
expect(fs.isExecutable(TEST_FILE_PATH)).toBeFalsy();
|
expect(fs.isExecutable(TEST_FILE_PATH)).toBeFalsy();
|
||||||
|
|
||||||
expect(fs.isReadable(ABSENT_FILE)).toBeFalsy();
|
expect(fs.isReadable(ABSENT_FILE)).toBeFalsy();
|
||||||
expect(fs.isWritable(ABSENT_FILE)).toBeFalsy();
|
expect(fs.isWritable(ABSENT_FILE)).toBeFalsy();
|
||||||
expect(fs.isExecutable(ABSENT_FILE)).toBeFalsy();
|
expect(fs.isExecutable(ABSENT_FILE)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should confirm that temporary directory is readable, writable and executable, while absent dir is none of those", function(){
|
it("should confirm that temporary directory is readable, writable and executable, while absent dir is none of those", function(){
|
||||||
expect(fs.isReadable(TEST_DIR)).toBeTruthy();
|
expect(fs.isReadable(TEST_DIR)).toBeTruthy();
|
||||||
expect(fs.isWritable(TEST_DIR)).toBeTruthy();
|
expect(fs.isWritable(TEST_DIR)).toBeTruthy();
|
||||||
expect(fs.isExecutable(TEST_DIR)).toBeTruthy();
|
expect(fs.isExecutable(TEST_DIR)).toBeTruthy();
|
||||||
|
|
||||||
expect(fs.isReadable(ABSENT_DIR)).toBeFalsy();
|
expect(fs.isReadable(ABSENT_DIR)).toBeFalsy();
|
||||||
expect(fs.isWritable(ABSENT_DIR)).toBeFalsy();
|
expect(fs.isWritable(ABSENT_DIR)).toBeFalsy();
|
||||||
expect(fs.isExecutable(ABSENT_DIR)).toBeFalsy();
|
expect(fs.isExecutable(ABSENT_DIR)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should confirm that neither temporary file/dir or absent file/dir are links", function(){
|
it("should confirm that neither temporary file/dir or absent file/dir are links", function(){
|
||||||
expect(fs.isLink(TEST_DIR)).toBeFalsy();
|
expect(fs.isLink(TEST_DIR)).toBeFalsy();
|
||||||
expect(fs.isLink(TEST_FILE_PATH)).toBeFalsy();
|
expect(fs.isLink(TEST_FILE_PATH)).toBeFalsy();
|
||||||
expect(fs.isLink(ABSENT_DIR)).toBeFalsy();
|
expect(fs.isLink(ABSENT_DIR)).toBeFalsy();
|
||||||
expect(fs.isLink(ABSENT_FILE)).toBeFalsy();
|
expect(fs.isLink(ABSENT_FILE)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should delete the temporary directory and file", function(){
|
it("should delete the temporary directory and file", function(){
|
||||||
fs.removeTree(TEST_DIR);
|
fs.removeTree(TEST_DIR);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -71,7 +71,7 @@ describe("phantom global object", function() {
|
||||||
expect(phantom.hasOwnProperty('cookiesEnabled')).toBeTruthy();
|
expect(phantom.hasOwnProperty('cookiesEnabled')).toBeTruthy();
|
||||||
expect(phantom.cookiesEnabled).toBeTruthy();
|
expect(phantom.cookiesEnabled).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to get the error signal handler that is currently set on it", function() {
|
it("should be able to get the error signal handler that is currently set on it", function() {
|
||||||
phantom.onError = undefined;
|
phantom.onError = undefined;
|
||||||
expect(phantom.onError).toBeUndefined();
|
expect(phantom.onError).toBeUndefined();
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
describe("WebKit", function() {
|
describe("WebKit", function() {
|
||||||
it("should construct date in mm-dd-yyyy format", function() {
|
it("should construct date in mm-dd-yyyy format", function() {
|
||||||
var date = new Date('2012-09-07');
|
var date = new Date('2012-09-07');
|
||||||
expect(date.toString()).toNotEqual('Invalid Date');
|
expect(date.toString()).toNotEqual('Invalid Date');
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should parse date in ISO8601 format (yyyy-mm-dd)", function() {
|
it("should parse date in ISO8601 format (yyyy-mm-dd)", function() {
|
||||||
var date = Date.parse("2012-01-01");
|
var date = Date.parse("2012-01-01");
|
||||||
expect(date).toEqual(1325376000000);
|
expect(date).toEqual(1325376000000);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not crash when failing to dirty lines while removing a inline.", function () {
|
it("should not crash when failing to dirty lines while removing a inline.", function () {
|
||||||
var p = require("webpage").create();
|
var p = require("webpage").create();
|
||||||
p.open('../test/webkit-spec/inline-destroy-dirty-lines-crash.html');
|
p.open('../test/webkit-spec/inline-destroy-dirty-lines-crash.html');
|
||||||
waits(50);
|
waits(50);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -135,7 +135,7 @@ describe("WebPage object", function() {
|
||||||
page.onConfirm = undefined;
|
page.onConfirm = undefined;
|
||||||
expect(page.onConfirm).toBeUndefined();
|
expect(page.onConfirm).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be able to get the error signal handler that is currently set on it (currently a special 1-off case)", function() {
|
it("should be able to get the error signal handler that is currently set on it (currently a special 1-off case)", function() {
|
||||||
page.onError = undefined;
|
page.onError = undefined;
|
||||||
expect(page.onError).toBeUndefined();
|
expect(page.onError).toBeUndefined();
|
||||||
|
@ -156,7 +156,7 @@ describe("WebPage object", function() {
|
||||||
checkPageCallback(page);
|
checkPageCallback(page);
|
||||||
checkPageConfirm(page);
|
checkPageConfirm(page);
|
||||||
checkPagePrompt(page);
|
checkPagePrompt(page);
|
||||||
|
|
||||||
checkClipRect(page, {height:0,left:0,top:0,width:0});
|
checkClipRect(page, {height:0,left:0,top:0,width:0});
|
||||||
|
|
||||||
expectHasPropertyString(page, 'content');
|
expectHasPropertyString(page, 'content');
|
||||||
|
@ -1023,22 +1023,22 @@ describe("WebPage object", function() {
|
||||||
expect(message).toEqual("PASS");
|
expect(message).toEqual("PASS");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should open url using secure connection', function() {
|
it('should open url using secure connection', function() {
|
||||||
var page = require('webpage').create();
|
var page = require('webpage').create();
|
||||||
var url = 'https://en.wikipedia.org';
|
var url = 'https://en.wikipedia.org';
|
||||||
|
|
||||||
var handled = false;
|
var handled = false;
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
page.open(url, function(status) {
|
page.open(url, function(status) {
|
||||||
expect(status == 'success').toEqual(true);
|
expect(status == 'success').toEqual(true);
|
||||||
handled = true;
|
handled = true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
waits(3000);
|
waits(3000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(handled).toEqual(true);
|
expect(handled).toEqual(true);
|
||||||
});
|
});
|
||||||
|
@ -1047,7 +1047,7 @@ describe("WebPage object", function() {
|
||||||
it('should handle resource request errors', function() {
|
it('should handle resource request errors', function() {
|
||||||
var server = require('webserver').create();
|
var server = require('webserver').create();
|
||||||
var page = require('webpage').create();
|
var page = require('webpage').create();
|
||||||
|
|
||||||
server.listen(12345, function(request, response) {
|
server.listen(12345, function(request, response) {
|
||||||
if (request.url == '/notExistResource.png') {
|
if (request.url == '/notExistResource.png') {
|
||||||
response.statusCode = 404;
|
response.statusCode = 404;
|
||||||
|
@ -1059,9 +1059,9 @@ describe("WebPage object", function() {
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var handled = false;
|
var handled = false;
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
page.onResourceError = function(errorCode, errorString) {
|
page.onResourceError = function(errorCode, errorString) {
|
||||||
expect(errorCode).toEqual(203);
|
expect(errorCode).toEqual(203);
|
||||||
|
@ -1073,23 +1073,23 @@ describe("WebPage object", function() {
|
||||||
expect(status).toEqual('success');
|
expect(status).toEqual('success');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
waits(5000);
|
waits(5000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(handled).toEqual(true);
|
expect(handled).toEqual(true);
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should able to abort a network request', function() {
|
it('should able to abort a network request', function() {
|
||||||
var page = require('webpage').create();
|
var page = require('webpage').create();
|
||||||
var url = 'http://phantomjs.org';
|
var url = 'http://phantomjs.org';
|
||||||
var urlToBlock = 'http://phantomjs.org/images/phantomjs-logo.png';
|
var urlToBlock = 'http://phantomjs.org/images/phantomjs-logo.png';
|
||||||
|
|
||||||
var handled = false;
|
var handled = false;
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
page.onResourceRequested = function(requestData, request) {
|
page.onResourceRequested = function(requestData, request) {
|
||||||
if (requestData['url'] == urlToBlock) {
|
if (requestData['url'] == urlToBlock) {
|
||||||
|
@ -1099,14 +1099,14 @@ describe("WebPage object", function() {
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
page.open(url, function(status) {
|
page.open(url, function(status) {
|
||||||
expect(status).toEqual('success');
|
expect(status).toEqual('success');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
waits(3000);
|
waits(3000);
|
||||||
|
|
||||||
runs(function() {
|
runs(function() {
|
||||||
expect(handled).toEqual(true);
|
expect(handled).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue