From c883a80caf8541d4ccf6c9410ddd62784c5951d9 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Tue, 2 Sep 2014 22:28:53 -0700 Subject: [PATCH] Port a few basic tests of global objects. https://github.com/ariya/phantomjs/issues/12439 --- test/basics/global.js | 21 +++++++++++++++++ test/basics/version.js | 12 ++++++++++ test/phantom-spec.js | 52 ------------------------------------------ test/run-tests.py | 2 ++ 4 files changed, 35 insertions(+), 52 deletions(-) create mode 100644 test/basics/global.js create mode 100644 test/basics/version.js diff --git a/test/basics/global.js b/test/basics/global.js new file mode 100644 index 00000000..6cb9575c --- /dev/null +++ b/test/basics/global.js @@ -0,0 +1,21 @@ +var assert = require('../assert'); + +assert.typeOf(phantom, 'object'); + +assert.isTrue(phantom.hasOwnProperty('libraryPath')); +assert.typeOf(phantom.libraryPath, 'string'); +assert.isTrue(phantom.libraryPath.length > 0); + +assert.isTrue(phantom.hasOwnProperty('outputEncoding')); +assert.typeOf(phantom.outputEncoding, 'string'); +assert.equal(phantom.outputEncoding.toLowerCase(), 'utf-8'); // default + +assert.isTrue(phantom.hasOwnProperty('injectJs')); +assert.typeOf(phantom.injectJs, 'function'); + +assert.isTrue(phantom.hasOwnProperty('exit')); +assert.typeOf(phantom.exit, 'function'); + +assert.isTrue(phantom.hasOwnProperty('cookiesEnabled')); +assert.typeOf(phantom.cookiesEnabled, 'boolean'); +assert.isTrue(phantom.cookiesEnabled); diff --git a/test/basics/version.js b/test/basics/version.js new file mode 100644 index 00000000..2fba55ed --- /dev/null +++ b/test/basics/version.js @@ -0,0 +1,12 @@ +var assert = require('../assert'); + +assert.isTrue(phantom.hasOwnProperty('version')); + +assert.typeOf(phantom.version, 'object'); +assert.typeOf(phantom.version.major, 'number'); +assert.typeOf(phantom.version.minor, 'number'); +assert.typeOf(phantom.version.patch, 'number'); + +assert.equal(phantom.version.major, 2); +assert.equal(phantom.version.minor, 0); +assert.equal(phantom.version.patch, 0); diff --git a/test/phantom-spec.js b/test/phantom-spec.js index 2430c0a4..0d100e36 100644 --- a/test/phantom-spec.js +++ b/test/phantom-spec.js @@ -1,56 +1,4 @@ describe("phantom global object", function() { - it("should exist", function() { - expect(typeof phantom).toEqual('object'); - }); - - it("should have libraryPath property", function() { - expect(phantom.hasOwnProperty('libraryPath')).toBeTruthy(); - }); - - it("should have libraryPath as a string", function() { - expect(typeof phantom.libraryPath).toEqual('string'); - }); - - it("should not have an empty libraryPath", function() { - expect(phantom.libraryPath.length).toNotEqual(0); - }); - - it("should have outputEncoding property", function() { - expect(phantom.hasOwnProperty('outputEncoding')).toBeTruthy(); - }); - - it("should have the default outputEncoding of UTF-8", function() { - expect(phantom.outputEncoding.toLowerCase()).toEqual('utf-8'); - }); - - it("should have version property", function() { - expect(phantom.hasOwnProperty('version')).toBeTruthy(); - }); - - it("should return 2 as the major version", function() { - expect(phantom.version.major).toEqual(2); - }); - - it("should return 0 as the minor version", function() { - expect(phantom.version.minor).toEqual(0); - }); - - it("should return 0 as the patch version", function() { - expect(phantom.version.patch).toEqual(0); - }); - - it("should have 'injectJs' function", function() { - expect(typeof phantom.injectJs).toEqual("function"); - }); - - it("should have 'exit' function", function() { - expect(typeof phantom.exit).toEqual("function"); - }); - - it("should have 'cookiesEnabled' property, and should be 'true' by default", 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; diff --git a/test/run-tests.py b/test/run-tests.py index cb244f6e..1f9be08c 100755 --- a/test/run-tests.py +++ b/test/run-tests.py @@ -11,6 +11,8 @@ TIMEOUT = 35 # Maximum duration of PhantomJS execution (in seconds) TESTS = [ 'basics/exit.js', + 'basics/global.js', + 'basics/version.js', 'module/system/system.js', 'module/system/args.js', 'module/system/os.js',