2011-07-25 11:25:09 +04:00
|
|
|
describe("phantom global object", function() {
|
|
|
|
it("should exist", function() {
|
|
|
|
expect(typeof phantom).toEqual('object');
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should have args property", function() {
|
|
|
|
expect(phantom.hasOwnProperty('args')).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should have args as an array", function() {
|
|
|
|
expect(typeof phantom.args).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 scriptName property", function() {
|
|
|
|
expect(phantom.hasOwnProperty('scriptName')).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should have scriptName as a string", function() {
|
|
|
|
expect(typeof phantom.scriptName).toEqual('string');
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should not have an empty scriptName", function() {
|
|
|
|
expect(phantom.scriptName.length).toNotEqual(0);
|
|
|
|
});
|
2011-08-21 09:53:22 +04:00
|
|
|
|
2011-08-21 09:56:08 +04:00
|
|
|
it("should have outputEncoding property", function() {
|
|
|
|
expect(phantom.hasOwnProperty('outputEncoding')).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
2011-08-22 19:54:10 +04:00
|
|
|
it("should have the default outputEncoding of UTF-8", function() {
|
2011-08-25 03:48:42 +04:00
|
|
|
expect(phantom.outputEncoding.toLowerCase()).toEqual('utf-8');
|
2011-08-21 09:56:08 +04:00
|
|
|
});
|
|
|
|
|
2011-08-21 09:53:22 +04:00
|
|
|
it("should have version property", function() {
|
|
|
|
expect(phantom.hasOwnProperty('version')).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should return 1 as the major version", function() {
|
|
|
|
expect(phantom.version.major).toEqual(1);
|
|
|
|
});
|
|
|
|
|
2013-03-31 14:06:50 +04:00
|
|
|
it("should return 10 as the minor version", function() {
|
|
|
|
expect(phantom.version.minor).toEqual(10);
|
2011-08-21 09:53:22 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should return 0 as the patch version", function() {
|
|
|
|
expect(phantom.version.patch).toEqual(0);
|
|
|
|
});
|
2011-08-21 10:47:39 +04:00
|
|
|
|
|
|
|
it("should have 'injectJs' function", function() {
|
|
|
|
expect(typeof phantom.injectJs).toEqual("function");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should have 'exit' function", function() {
|
|
|
|
expect(typeof phantom.exit).toEqual("function");
|
|
|
|
});
|
2012-07-04 14:59:24 +04:00
|
|
|
|
2012-09-06 10:33:18 +04:00
|
|
|
it("should have 'cookiesEnabled' property, and should be 'true' by default", function() {
|
|
|
|
expect(phantom.hasOwnProperty('cookiesEnabled')).toBeTruthy();
|
|
|
|
expect(phantom.cookiesEnabled).toBeTruthy();
|
|
|
|
});
|
2013-01-18 03:52:47 +04:00
|
|
|
|
2012-12-11 04:52:27 +04:00
|
|
|
it("should be able to get the error signal handler that is currently set on it", function() {
|
|
|
|
phantom.onError = undefined;
|
|
|
|
expect(phantom.onError).toBeUndefined();
|
|
|
|
var onErrorFunc1 = function() { return !"x"; };
|
|
|
|
phantom.onError = onErrorFunc1;
|
|
|
|
expect(phantom.onError).toEqual(onErrorFunc1);
|
|
|
|
var onErrorFunc2 = function() { return !!"y"; };
|
|
|
|
phantom.onError = onErrorFunc2;
|
|
|
|
expect(phantom.onError).toEqual(onErrorFunc2);
|
|
|
|
expect(phantom.onError).toNotEqual(onErrorFunc1);
|
|
|
|
phantom.onError = null;
|
|
|
|
// Will only allow setting to a function value, so setting it to `null` returns `undefined`
|
|
|
|
expect(phantom.onError).toBeUndefined();
|
|
|
|
phantom.onError = undefined;
|
|
|
|
expect(phantom.onError).toBeUndefined();
|
|
|
|
});
|
2011-07-25 11:25:09 +04:00
|
|
|
});
|