Fixing up indentation for our Jasmine test specs.

Just getting rid of an itch of mine.
1.9
Ivan De Marino 2013-01-17 23:52:47 +00:00
parent 12bb24f418
commit 7e7325c0f5
7 changed files with 263 additions and 263 deletions

View File

@ -1,9 +1,9 @@
describe("Basic Files API (read, write, remove, ...)", function() {
var FILENAME = "temp-01.test",
FILENAME_COPY = FILENAME + ".copy",
FILENAME_MOVED = FILENAME + ".moved",
FILENAME_EMPTY = FILENAME + ".empty",
FILENAME_ENC = FILENAME + ".enc",
FILENAME_COPY = FILENAME + ".copy",
FILENAME_MOVED = FILENAME + ".moved",
FILENAME_EMPTY = FILENAME + ".empty",
FILENAME_ENC = FILENAME + ".enc",
FILENAME_BIN = FILENAME + ".bin",
ABSENT = "absent-01.test";
@ -19,12 +19,12 @@ describe("Basic Files API (read, write, remove, ...)", function() {
expect(fs.exists(FILENAME)).toBeTruthy();
});
it("should be able to create (touch) an empty file", function() {
expect(fs.exists(FILENAME_EMPTY)).toBeFalsy();
fs.touch(FILENAME_EMPTY);
expect(fs.exists(FILENAME_EMPTY)).toBeTruthy();
expect(fs.size(FILENAME_EMPTY)).toEqual(0);
});
it("should be able to create (touch) an empty file", function() {
expect(fs.exists(FILENAME_EMPTY)).toBeFalsy();
fs.touch(FILENAME_EMPTY);
expect(fs.exists(FILENAME_EMPTY)).toBeTruthy();
expect(fs.size(FILENAME_EMPTY)).toEqual(0);
});
it("should be able to read content from a file", function() {
var content = "";
@ -59,35 +59,35 @@ describe("Basic Files API (read, write, remove, ...)", function() {
expect(content).toEqual("hello\nworld\nasdf\n");
});
it("should be able to copy a file", function() {
expect(fs.exists(FILENAME_COPY)).toBeFalsy();
fs.copy(FILENAME, FILENAME_COPY);
expect(fs.exists(FILENAME_COPY)).toBeTruthy();
expect(fs.read(FILENAME)).toEqual(fs.read(FILENAME_COPY));
});
it("should be able to copy a file", function() {
expect(fs.exists(FILENAME_COPY)).toBeFalsy();
fs.copy(FILENAME, FILENAME_COPY);
expect(fs.exists(FILENAME_COPY)).toBeTruthy();
expect(fs.read(FILENAME)).toEqual(fs.read(FILENAME_COPY));
});
it("should be able to move a file", function() {
expect(fs.exists(FILENAME)).toBeTruthy();
var contentBeforeMove = fs.read(FILENAME);
fs.move(FILENAME, FILENAME_MOVED);
expect(fs.exists(FILENAME)).toBeFalsy();
expect(fs.exists(FILENAME_MOVED)).toBeTruthy();
expect(fs.read(FILENAME_MOVED)).toEqual(contentBeforeMove);
});
it("should be able to move a file", function() {
expect(fs.exists(FILENAME)).toBeTruthy();
var contentBeforeMove = fs.read(FILENAME);
fs.move(FILENAME, FILENAME_MOVED);
expect(fs.exists(FILENAME)).toBeFalsy();
expect(fs.exists(FILENAME_MOVED)).toBeTruthy();
expect(fs.read(FILENAME_MOVED)).toEqual(contentBeforeMove);
});
it("should be able to remove a (moved) file", function() {
expect(fs.exists(FILENAME_MOVED)).toBeTruthy();
fs.remove(FILENAME_MOVED);
expect(fs.exists(FILENAME_MOVED)).toBeTruthy();
fs.remove(FILENAME_MOVED);
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();
fs.remove(FILENAME_COPY);
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();
fs.remove(FILENAME_EMPTY);
expect(fs.exists(FILENAME_EMPTY)).toBeFalsy();
@ -99,27 +99,27 @@ describe("Basic Files API (read, write, remove, ...)", function() {
}).toThrow("Unable to open file '"+ ABSENT +"'");
});
it("should throw an exception when trying to copy a non existing file", function() {
expect(function(){
fs.copy(ABSENT, FILENAME_COPY);
}).toThrow("Unable to copy file '" + ABSENT + "' at '" + FILENAME_COPY + "'");
});
it("should throw an exception when trying to copy a non existing file", function() {
expect(function(){
fs.copy(ABSENT, FILENAME_COPY);
}).toThrow("Unable to copy file '" + ABSENT + "' at '" + FILENAME_COPY + "'");
});
it("should be read/write utf8 text by default", function() {
var content, output = "ÄABCÖ";
try {
var f = fs.open(FILENAME_ENC, "w");
f.write(output);
f.close();
it("should be read/write utf8 text by default", function() {
var content, output = "ÄABCÖ";
try {
var f = fs.open(FILENAME_ENC, "w");
f.write(output);
f.close();
f = fs.open(FILENAME_ENC, "r");
content = f.read();
f.close();
f = fs.open(FILENAME_ENC, "r");
content = f.read();
f.close();
fs.remove(FILENAME_ENC);
} catch (e) { }
expect(content).toEqual(output);
});
fs.remove(FILENAME_ENC);
} catch (e) { }
expect(content).toEqual(output);
});
it("should be read/write binary data", function() {
var content, output = String.fromCharCode(0, 1, 2, 3, 4, 5);

View File

@ -1,137 +1,137 @@
describe("Files and Directories API", function() {
var TEST_DIR = "testdir",
TEST_FILE = "testfile",
START_CWD = fs.workingDirectory;
var TEST_DIR = "testdir",
TEST_FILE = "testfile",
START_CWD = fs.workingDirectory;
it("should create a new temporary directory and change the Current Working Directory to it", function() {
expect(fs.makeDirectory(TEST_DIR)).toBeTruthy();
expect(fs.changeWorkingDirectory(TEST_DIR)).toBeTruthy();
});
it("should create a new temporary directory and change the Current Working Directory to it", function() {
expect(fs.makeDirectory(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() {
fs.write(TEST_FILE, TEST_FILE, "w");
var suffix = fs.join("", TEST_DIR, TEST_FILE),
abs = fs.absolute(".." + suffix),
lastIndex = abs.lastIndexOf(suffix);
expect(lastIndex).toNotEqual(-1);
expect(lastIndex + suffix.length === abs.length);
});
it("should create a file in the Current Working Directory and check it's absolute path", function() {
fs.write(TEST_FILE, TEST_FILE, "w");
var suffix = fs.join("", TEST_DIR, TEST_FILE),
abs = fs.absolute(".." + suffix),
lastIndex = abs.lastIndexOf(suffix);
expect(lastIndex).toNotEqual(-1);
expect(lastIndex + suffix.length === abs.length);
});
it("should return to previous Current Working Directory and remove temporary directory", function() {
expect(fs.changeWorkingDirectory(START_CWD)).toBeTruthy();
fs.removeTree(TEST_DIR);
});
it("should return to previous Current Working Directory and remove temporary directory", function() {
expect(fs.changeWorkingDirectory(START_CWD)).toBeTruthy();
fs.removeTree(TEST_DIR);
});
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;
fs.copyTree(phantom.libraryPath, "/tmp/"+TEST_DIR);
expect(phantomLibraryPathListingLength === fs.list("/tmp/"+TEST_DIR).length);
fs.removeTree("/tmp/"+TEST_DIR);
});
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;
fs.copyTree(phantom.libraryPath, "/tmp/"+TEST_DIR);
expect(phantomLibraryPathListingLength === fs.list("/tmp/"+TEST_DIR).length);
fs.removeTree("/tmp/"+TEST_DIR);
});
// TODO: test the actual functionality once we can create symlink.
it("should have readLink function", function() {
expect(typeof fs.readLink).toEqual('function');
expect(typeof fs.readLink).toEqual('function');
});
fs.removeTree(TEST_DIR);
describe("fs.join(...)", function() {
var parts, expected, actual;
var parts, expected, actual;
it("empty parts", function() {
parts = [];
expected = ".";
actual = fs.join.apply(null, parts);
expect(actual).toEqual(expected);
});
it("empty parts", function() {
parts = [];
expected = ".";
actual = fs.join.apply(null, parts);
expect(actual).toEqual(expected);
});
it("one part (empty string)", function() {
parts = [""];
expected = ".";
actual = fs.join.apply(null, parts);
expect(actual).toEqual(expected);
});
it("one part (empty string)", function() {
parts = [""];
expected = ".";
actual = fs.join.apply(null, parts);
expect(actual).toEqual(expected);
});
it("one part (array)", function() {
parts = [[], null];
expected = ".";
actual = fs.join.apply(null, parts);
expect(actual).toEqual(expected);
});
it("one part (array)", function() {
parts = [[], null];
expected = ".";
actual = fs.join.apply(null, parts);
expect(actual).toEqual(expected);
});
it("empty string and one part", function() {
parts = ["", "a"];
expected = "/a";
actual = fs.join.apply(null, parts);
expect(actual).toEqual(expected);
});
it("empty string and one part", function() {
parts = ["", "a"];
expected = "/a";
actual = fs.join.apply(null, parts);
expect(actual).toEqual(expected);
});
it("empty string and multiple parts", function() {
parts = ["", "a", "b", "c"];
expected = "/a/b/c";
actual = fs.join.apply(null, parts);
expect(actual).toEqual(expected);
});
it("empty string and multiple parts", function() {
parts = ["", "a", "b", "c"];
expected = "/a/b/c";
actual = fs.join.apply(null, parts);
expect(actual).toEqual(expected);
});
it("empty string and multiple parts with empty strings", function() {
parts = ["", "a", "", "b", "", "c"];
expected = "/a/b/c";
actual = fs.join.apply(null, parts);
expect(actual).toEqual(expected);
});
it("empty string and multiple parts with empty strings", function() {
parts = ["", "a", "", "b", "", "c"];
expected = "/a/b/c";
actual = fs.join.apply(null, parts);
expect(actual).toEqual(expected);
});
it("multiple parts", function() {
parts = ["a", "b", "c"];
expected = "a/b/c";
actual = fs.join.apply(null, parts);
expect(actual).toEqual(expected);
});
it("multiple parts", function() {
parts = ["a", "b", "c"];
expected = "a/b/c";
actual = fs.join.apply(null, parts);
expect(actual).toEqual(expected);
});
it("multiple parts with empty strings", function() {
parts = ["a", "", "b", "", "c"];
expected = "a/b/c";
actual = fs.join.apply(null, parts);
expect(actual).toEqual(expected);
});
it("multiple parts with empty strings", function() {
parts = ["a", "", "b", "", "c"];
expected = "a/b/c";
actual = fs.join.apply(null, parts);
expect(actual).toEqual(expected);
});
});
describe("fs.split(path)", function() {
var path, expected, actual;
var path, expected, actual;
it("should split absolute path with trailing separator", function() {
path = fs.separator + "a" + fs.separator + "b" + fs.separator + "c" + fs.separator + "d" + fs.separator;
actual = fs.split(path);
expected = ["", "a", "b", "c", "d"];
expect(actual).toEqual(expected);
});
it("should split absolute path with trailing separator", function() {
path = fs.separator + "a" + fs.separator + "b" + fs.separator + "c" + fs.separator + "d" + fs.separator;
actual = fs.split(path);
expected = ["", "a", "b", "c", "d"];
expect(actual).toEqual(expected);
});
it("should split absolute path without trailing separator", function() {
path = fs.separator + "a" + fs.separator + "b" + fs.separator + "c" + fs.separator + "d";
actual = fs.split(path);
expected = ["", "a", "b", "c", "d"];
expect(actual).toEqual(expected);
});
it("should split absolute path without trailing separator", function() {
path = fs.separator + "a" + fs.separator + "b" + fs.separator + "c" + fs.separator + "d";
actual = fs.split(path);
expected = ["", "a", "b", "c", "d"];
expect(actual).toEqual(expected);
});
it("should split non-absolute path with trailing separator", function() {
path = "a" + fs.separator + "b" + fs.separator + "c" + fs.separator + "d" + fs.separator;
actual = fs.split(path);
expected = ["a", "b", "c", "d"];
expect(actual).toEqual(expected);
});
it("should split non-absolute path with trailing separator", function() {
path = "a" + fs.separator + "b" + fs.separator + "c" + fs.separator + "d" + fs.separator;
actual = fs.split(path);
expected = ["a", "b", "c", "d"];
expect(actual).toEqual(expected);
});
it("should split non-absolute path without trailing separator", function() {
path = "a" + fs.separator + "b" + fs.separator + "c" + fs.separator + "d";
actual = fs.split(path);
expected = ["a", "b", "c", "d"];
expect(actual).toEqual(expected);
});
it("should split non-absolute path without trailing separator", function() {
path = "a" + fs.separator + "b" + fs.separator + "c" + fs.separator + "d";
actual = fs.split(path);
expected = ["a", "b", "c", "d"];
expect(actual).toEqual(expected);
});
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;
expected = ["a", "b", "c", "d"];
actual = fs.split(path);
expect(actual).toEqual(expected);
});
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;
expected = ["a", "b", "c", "d"];
actual = fs.split(path);
expect(actual).toEqual(expected);
});
});
});

View File

@ -1,70 +1,70 @@
describe("Tests Files API", function() {
var ABSENT_DIR = "absentdir04",
ABSENT_FILE = "absentfile04",
TEST_DIR = "testdir04",
TEST_FILE = "testfile04",
TEST_FILE_PATH = fs.join(TEST_DIR, TEST_FILE),
TEST_CONTENT = "test content",
START_CWD = null;
var ABSENT_DIR = "absentdir04",
ABSENT_FILE = "absentfile04",
TEST_DIR = "testdir04",
TEST_FILE = "testfile04",
TEST_FILE_PATH = fs.join(TEST_DIR, TEST_FILE),
TEST_CONTENT = "test content",
START_CWD = null;
it("should create some temporary file and directory", function(){
fs.makeDirectory(TEST_DIR);
fs.write(TEST_FILE_PATH, TEST_CONTENT, "w");
});
it("should create some temporary file and directory", function(){
fs.makeDirectory(TEST_DIR);
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(){
expect(fs.exists(TEST_FILE_PATH)).toBeTruthy();
expect(fs.exists(TEST_DIR)).toBeTruthy();
expect(fs.exists(ABSENT_FILE)).toBeFalsy();
expect(fs.exists(ABSENT_DIR)).toBeFalsy();
});
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_DIR)).toBeTruthy();
expect(fs.exists(ABSENT_FILE)).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(){
expect(fs.isDirectory(TEST_DIR)).toBeTruthy();
expect(fs.isDirectory(ABSENT_DIR)).toBeFalsy();
});
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(ABSENT_DIR)).toBeFalsy();
});
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(ABSENT_FILE)).toBeFalsy();
});
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(ABSENT_FILE)).toBeFalsy();
});
it("should confirm that a relative path is not absolute, while an absolute one is", function(){
var absPath = fs.absolute(TEST_FILE_PATH);
it("should confirm that a relative path is not absolute, while an absolute one is", function(){
var absPath = fs.absolute(TEST_FILE_PATH);
expect(fs.isAbsolute(TEST_FILE_PATH)).toBeFalsy();
expect(fs.isAbsolute(absPath)).toBeTruthy();
});
expect(fs.isAbsolute(TEST_FILE_PATH)).toBeFalsy();
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(){
expect(fs.isReadable(TEST_FILE_PATH)).toBeTruthy();
expect(fs.isWritable(TEST_FILE_PATH)).toBeTruthy();
expect(fs.isExecutable(TEST_FILE_PATH)).toBeFalsy();
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.isWritable(TEST_FILE_PATH)).toBeTruthy();
expect(fs.isExecutable(TEST_FILE_PATH)).toBeFalsy();
expect(fs.isReadable(ABSENT_FILE)).toBeFalsy();
expect(fs.isWritable(ABSENT_FILE)).toBeFalsy();
expect(fs.isExecutable(ABSENT_FILE)).toBeFalsy();
});
expect(fs.isReadable(ABSENT_FILE)).toBeFalsy();
expect(fs.isWritable(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(){
expect(fs.isReadable(TEST_DIR)).toBeTruthy();
expect(fs.isWritable(TEST_DIR)).toBeTruthy();
expect(fs.isExecutable(TEST_DIR)).toBeTruthy();
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.isWritable(TEST_DIR)).toBeTruthy();
expect(fs.isExecutable(TEST_DIR)).toBeTruthy();
expect(fs.isReadable(ABSENT_DIR)).toBeFalsy();
expect(fs.isWritable(ABSENT_DIR)).toBeFalsy();
expect(fs.isExecutable(ABSENT_DIR)).toBeFalsy();
});
expect(fs.isReadable(ABSENT_DIR)).toBeFalsy();
expect(fs.isWritable(ABSENT_DIR)).toBeFalsy();
expect(fs.isExecutable(ABSENT_DIR)).toBeFalsy();
});
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_FILE_PATH)).toBeFalsy();
expect(fs.isLink(ABSENT_DIR)).toBeFalsy();
expect(fs.isLink(ABSENT_FILE)).toBeFalsy();
});
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_FILE_PATH)).toBeFalsy();
expect(fs.isLink(ABSENT_DIR)).toBeFalsy();
expect(fs.isLink(ABSENT_FILE)).toBeFalsy();
});
it("should delete the temporary directory and file", function(){
fs.removeTree(TEST_DIR);
});
it("should delete the temporary directory and file", function(){
fs.removeTree(TEST_DIR);
});
});

View File

@ -1,17 +1,17 @@
describe("WebKit", function() {
it("should construct date in mm-dd-yyyy format", function() {
var date = new Date('2012-09-07');
expect(date.toString()).toNotEqual('Invalid Date');
});
it("should construct date in mm-dd-yyyy format", function() {
var date = new Date('2012-09-07');
expect(date.toString()).toNotEqual('Invalid Date');
});
it("should parse date in ISO8601 format (yyyy-mm-dd)", function() {
var date = Date.parse("2012-01-01");
expect(date).toEqual(1325376000000);
});
it("should parse date in ISO8601 format (yyyy-mm-dd)", function() {
var date = Date.parse("2012-01-01");
expect(date).toEqual(1325376000000);
});
it("should not crash when failing to dirty lines while removing a inline.", function () {
var p = require("webpage").create();
p.open('../test/webkit-spec/inline-destroy-dirty-lines-crash.html');
waits(50);
});
it("should not crash when failing to dirty lines while removing a inline.", function () {
var p = require("webpage").create();
p.open('../test/webkit-spec/inline-destroy-dirty-lines-crash.html');
waits(50);
});
});