From 7e7325c0f5acb0996df701e5fb9233d85aef700d Mon Sep 17 00:00:00 2001 From: Ivan De Marino Date: Thu, 17 Jan 2013 23:52:47 +0000 Subject: [PATCH] Fixing up indentation for our Jasmine test specs. Just getting rid of an itch of mine. --- test/fs-spec-01.js | 92 +++++++++---------- test/fs-spec-02.js | 14 +-- test/fs-spec-03.js | 212 +++++++++++++++++++++---------------------- test/fs-spec-04.js | 138 ++++++++++++++-------------- test/phantom-spec.js | 2 +- test/webkit-spec.js | 32 +++---- test/webpage-spec.js | 36 ++++---- 7 files changed, 263 insertions(+), 263 deletions(-) diff --git a/test/fs-spec-01.js b/test/fs-spec-01.js index c759cd6a..71b0c297 100644 --- a/test/fs-spec-01.js +++ b/test/fs-spec-01.js @@ -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); diff --git a/test/fs-spec-02.js b/test/fs-spec-02.js index 32aed558..2407743b 100644 --- a/test/fs-spec-02.js +++ b/test/fs-spec-02.js @@ -9,15 +9,15 @@ describe("Attributes Files API", function() { fs.size(ABSENT); }).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(){ expect(fs.lastModified(ABSENT)).toBeNull(); }); - + it("should create temporary file '"+ FILENAME +"' and writes some content in it", function(){ try{ var f = fs.open(FILENAME, "w"); - + expect(f).toBeDefined(); for (var i = 1; i <= CONTENT_MULTIPLIER; ++i) { f.write(CONTENT); @@ -25,11 +25,11 @@ describe("Attributes Files API", function() { f.close(); } catch (e) { } }); - + it("should be able to read the size of a temporary file '"+ FILENAME +"'", function() { 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() { var flm = fs.lastModified(FILENAME), now = new Date(); @@ -39,8 +39,8 @@ describe("Attributes Files API", function() { expect(now.getFullYear()).toEqual(flm.getFullYear()); expect(now.getMilliseconds()).toNotEqual(flm.getMilliseconds()); }); - + it("should remove temporary file '"+ FILENAME +"'", function(){ fs.remove(FILENAME); }); -}); \ No newline at end of file +}); diff --git a/test/fs-spec-03.js b/test/fs-spec-03.js index 77f312e3..841cdc51 100644 --- a/test/fs-spec-03.js +++ b/test/fs-spec-03.js @@ -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); + }); }); }); diff --git a/test/fs-spec-04.js b/test/fs-spec-04.js index 6545490d..2d75eeb4 100644 --- a/test/fs-spec-04.js +++ b/test/fs-spec-04.js @@ -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; - - 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 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 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(); - }); - - 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(); - }); - - 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(); - }); - - 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); - }); - -}); \ No newline at end of file + 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 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 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); + + 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(); + + 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(); + + 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 delete the temporary directory and file", function(){ + fs.removeTree(TEST_DIR); + }); + +}); diff --git a/test/phantom-spec.js b/test/phantom-spec.js index 59727486..369b2f70 100644 --- a/test/phantom-spec.js +++ b/test/phantom-spec.js @@ -71,7 +71,7 @@ describe("phantom global object", function() { expect(phantom.hasOwnProperty('cookiesEnabled')).toBeTruthy(); expect(phantom.cookiesEnabled).toBeTruthy(); }); - + it("should be able to get the error signal handler that is currently set on it", function() { phantom.onError = undefined; expect(phantom.onError).toBeUndefined(); diff --git a/test/webkit-spec.js b/test/webkit-spec.js index a7c4f557..5d391959 100644 --- a/test/webkit-spec.js +++ b/test/webkit-spec.js @@ -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 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); - }); -}); \ No newline at end of file + 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 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); + }); +}); diff --git a/test/webpage-spec.js b/test/webpage-spec.js index ba16b9e3..a8fb6039 100644 --- a/test/webpage-spec.js +++ b/test/webpage-spec.js @@ -135,7 +135,7 @@ describe("WebPage object", function() { page.onConfirm = undefined; 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() { page.onError = undefined; expect(page.onError).toBeUndefined(); @@ -156,7 +156,7 @@ describe("WebPage object", function() { checkPageCallback(page); checkPageConfirm(page); checkPagePrompt(page); - + checkClipRect(page, {height:0,left:0,top:0,width:0}); expectHasPropertyString(page, 'content'); @@ -1023,22 +1023,22 @@ describe("WebPage object", function() { expect(message).toEqual("PASS"); }); }); - + it('should open url using secure connection', function() { var page = require('webpage').create(); var url = 'https://en.wikipedia.org'; - + var handled = false; - + runs(function() { page.open(url, function(status) { expect(status == 'success').toEqual(true); handled = true; }); }); - + waits(3000); - + runs(function() { expect(handled).toEqual(true); }); @@ -1047,7 +1047,7 @@ describe("WebPage object", function() { it('should handle resource request errors', function() { var server = require('webserver').create(); var page = require('webpage').create(); - + server.listen(12345, function(request, response) { if (request.url == '/notExistResource.png') { response.statusCode = 404; @@ -1059,9 +1059,9 @@ describe("WebPage object", function() { response.close(); } }); - + var handled = false; - + runs(function() { page.onResourceError = function(errorCode, errorString) { expect(errorCode).toEqual(203); @@ -1073,23 +1073,23 @@ describe("WebPage object", function() { expect(status).toEqual('success'); }); }); - + waits(5000); - + runs(function() { expect(handled).toEqual(true); server.close(); }); }); - + it('should able to abort a network request', function() { var page = require('webpage').create(); var url = 'http://phantomjs.org'; var urlToBlock = 'http://phantomjs.org/images/phantomjs-logo.png'; - + var handled = false; - + runs(function() { page.onResourceRequested = function(requestData, request) { if (requestData['url'] == urlToBlock) { @@ -1099,14 +1099,14 @@ describe("WebPage object", function() { handled = true; } }; - + page.open(url, function(status) { expect(status).toEqual('success'); }); }); - + waits(3000); - + runs(function() { expect(handled).toEqual(true); });