mirror of https://github.com/vitalif/phantomjs
commit
43a987d5b4
|
@ -2,8 +2,30 @@
|
|||
phantom.injectJs("./lib/jasmine.js");
|
||||
phantom.injectJs("./lib/jasmine-console.js");
|
||||
|
||||
// Helper funcs
|
||||
function expectHasFunction(o, name) {
|
||||
it("should have '" + name + "' function", function() {
|
||||
expect(typeof o[name]).toEqual('function');
|
||||
});
|
||||
}
|
||||
|
||||
function expectHasProperty(o, name) {
|
||||
it("should have '" + name + "' property", function() {
|
||||
expect(o.hasOwnProperty(name)).toBeTruthy();
|
||||
});
|
||||
}
|
||||
|
||||
function expectHasPropertyString(o, name) {
|
||||
expectHasProperty(o, name);
|
||||
|
||||
it("should have '" + name + "' as a string", function() {
|
||||
expect(typeof o[name]).toEqual('string');
|
||||
});
|
||||
}
|
||||
|
||||
// Load specs
|
||||
phantom.injectJs("./phantom-spec.js");
|
||||
phantom.injectJs("./webpage-spec.js");
|
||||
phantom.injectJs("./fs-spec-01.js"); //< Filesystem Specs 01 (Basic)
|
||||
phantom.injectJs("./fs-spec-02.js"); //< Filesystem Specs 02 (Attributes)
|
||||
phantom.injectJs("./fs-spec-03.js"); //< Filesystem Specs 03 (Paths)
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
describe("WebPage constructor", function() {
|
||||
it("should exist in window", function() {
|
||||
expect(window.hasOwnProperty('WebPage')).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should be a function", function() {
|
||||
expect(typeof window.WebPage).toEqual('function');
|
||||
});
|
||||
});
|
||||
|
||||
describe("WebPage object", function() {
|
||||
var page = new WebPage();
|
||||
|
||||
it("should be creatable", function() {
|
||||
expect(typeof page).toEqual('object');
|
||||
expect(page).toNotEqual(null);
|
||||
});
|
||||
|
||||
expectHasProperty(page, 'clipRect');
|
||||
it("should have clipRect with height 0", function() {
|
||||
expect(page.clipRect.height).toEqual(0);
|
||||
});
|
||||
it("should have clipRect with left 0", function() {
|
||||
expect(page.clipRect.left).toEqual(0);
|
||||
});
|
||||
it("should have clipRect with top 0", function() {
|
||||
expect(page.clipRect.top).toEqual(0);
|
||||
});
|
||||
it("should have clipRect with width 0", function() {
|
||||
expect(page.clipRect.width).toEqual(0);
|
||||
});
|
||||
|
||||
expectHasPropertyString(page, 'content');
|
||||
|
||||
expectHasPropertyString(page, 'libraryPath');
|
||||
it("should have objectName as 'WebPage'", function() {
|
||||
expect(page.objectName).toEqual('WebPage');
|
||||
});
|
||||
|
||||
expectHasProperty(page, 'paperSize');
|
||||
it("should have paperSize as an empty object", function() {
|
||||
expect(page.paperSize).toEqual({});
|
||||
});
|
||||
|
||||
expectHasProperty(page, 'scrollPosition');
|
||||
it("should have scrollPosition with left 0", function() {
|
||||
expect(page.scrollPosition.left).toEqual(0);
|
||||
});
|
||||
it("should have scrollPosition with top 0", function() {
|
||||
expect(page.scrollPosition.top).toEqual(0);
|
||||
});
|
||||
|
||||
expectHasProperty(page, 'settings');
|
||||
it("should have non-empty settings", function() {
|
||||
expect(page.settings).toNotEqual(null);
|
||||
expect(page.settings).toNotEqual({});
|
||||
});
|
||||
|
||||
|
||||
expectHasProperty(page, 'viewportSize');
|
||||
it("should have viewportSize with height 300", function() {
|
||||
expect(page.viewportSize.height).toEqual(300);
|
||||
});
|
||||
it("should have viewportSize with width 400", function() {
|
||||
expect(page.viewportSize.width).toEqual(400);
|
||||
});
|
||||
|
||||
expectHasFunction(page, '_appendScriptElement');
|
||||
expectHasFunction(page, 'click');
|
||||
expectHasFunction(page, 'deleteLater');
|
||||
expectHasFunction(page, 'destroyed');
|
||||
expectHasFunction(page, 'evaluate');
|
||||
expectHasFunction(page, 'initialized');
|
||||
expectHasFunction(page, 'injectJs');
|
||||
expectHasFunction(page, 'javaScriptAlertSent');
|
||||
expectHasFunction(page, 'javaScriptConsoleMessageSent');
|
||||
expectHasFunction(page, 'loadFinished');
|
||||
expectHasFunction(page, 'loadStarted');
|
||||
expectHasFunction(page, 'mouseDown');
|
||||
expectHasFunction(page, 'mouseMoveTo');
|
||||
expectHasFunction(page, 'mouseUp');
|
||||
expectHasFunction(page, 'openUrl');
|
||||
expectHasFunction(page, 'release');
|
||||
expectHasFunction(page, 'render');
|
||||
expectHasFunction(page, 'resourceReceived');
|
||||
expectHasFunction(page, 'resourceRequested');
|
||||
expectHasFunction(page, 'uploadFile');
|
||||
});
|
Loading…
Reference in New Issue