Removed references to 'window'; using jasmine.getGlobal() instead in order to better support non-browser environments.

Better protection around access to console.
The global object is now pretty-printed as "<global>", not "<window>".
Tests are a little closer to passing in node.js.
This commit is contained in:
Lee Byrd & Christian Williams
2010-06-22 16:22:09 -07:00
parent e60f22a2e5
commit 01d842fdfd
10 changed files with 69 additions and 62 deletions

View File

@@ -1,24 +0,0 @@
local:
application_framework: :selenium
#
# Possible Sauce Labs configurations as of 2009/11/19
# From: http://saucelabs.com/products/docs/sauce-ondemand/browsers
# os: "Windows 2003"
# browser: "iexplore"
# browser-version: "6.", "7.", "8."
# browser: "firefox"
# browser-version: "2.", "3.0", "3.5"
# browser: "safari"
# browser-version: "3.", "4."
# browser: "opera"
# browser-version: "9."
# browser: "googlechrome"
# browser-version: ""
# os: "Linux"
# browser: "firefox"
# browser-version: "3."
saucelabs:
application_framework: :external
selenium_server_address: "saucelabs.com"
selenium_browser_key: '{"username": "--YOUR-SAUCELABS-USERNAME--", "access-key": "--YOUR-SAUCELABS-ACCESS-KEY--", "os": "Linux", "browser": "firefox", "browser-version": "3."}'
application_port: "80"

View File

@@ -12,4 +12,14 @@ describe("jasmine.log", function() {
jasmine.log(1, 2, 3);
expect(jasmine.getEnv().currentSpec.log).wasCalledWith(1, 2, 3);
});
});
describe("jasmine.getGlobal", function() {
it("should return the global object", function() {
var globalObject = (function() {
return this;
})();
expect(jasmine.getGlobal()).toBe(globalObject);
});
});

View File

@@ -20,7 +20,7 @@ describe("jasmine.Matchers", function() {
return spec.addMatcherResult.mostRecentCall.args[0];
}
it("toEqual with primitives, objects, dates, html nodes, etc.", function() {
it("toEqual with primitives, objects, dates, etc.", function() {
expect(match(true).toEqual(true)).toEqual(true);
expect(match({foo:'bar'}).toEqual(null)).toEqual(false);
@@ -40,11 +40,6 @@ describe("jasmine.Matchers", function() {
circularGraph.referenceToSelf = circularGraph;
expect((match(circularGraph).toEqual(circularGraph))).toEqual(true);
var nodeA = document.createElement('div');
var nodeB = document.createElement('div');
expect((match(nodeA).toEqual(nodeA))).toEqual(true);
expect((match(nodeA).toEqual(nodeB))).toEqual(false);
expect((match(new Date(2008, 1, 3, 15, 17, 19, 1234)).toEqual(new Date(2009, 1, 3, 15, 17, 19, 1234)))).toEqual(false);
expect((match(new Date(2008, 1, 3, 15, 17, 19, 1234)).toEqual(new Date(2008, 1, 3, 15, 17, 19, 1234)))).toEqual(true);
@@ -64,6 +59,13 @@ describe("jasmine.Matchers", function() {
expect((match(new Number('5')).toNotEqual(5))).toBe(false);
});
it("toEqual with DOM nodes", function() {
var nodeA = document.createElement('div');
var nodeB = document.createElement('div');
expect((match(nodeA).toEqual(nodeA))).toEqual(true);
expect((match(nodeA).toEqual(nodeB))).toEqual(false);
});
it("toEqual to build an Expectation Result", function() {
var actual = 'a';
var matcher = match(actual);

View File

@@ -69,8 +69,8 @@ describe("jasmine.pp", function () {
expect(jasmine.pp('some <b>html string</b> &', false)).toEqual('\'some <b>html string</b> &\'');
});
it("should abbreviate window objects", function() {
expect(jasmine.pp(window)).toEqual("<window>");
it("should abbreviate the global (usually window) object", function() {
expect(jasmine.pp(jasmine.getGlobal())).toEqual("<global>");
});
it("should stringify Date objects properly", function() {