Minor test fixup to support env-js DOM implementation

This commit is contained in:
ragaskar 2009-03-01 07:38:00 -08:00
parent 3d1fb9bc3a
commit 2032f51460
1 changed files with 19 additions and 12 deletions

31
test/bootstrap.js vendored
View File

@ -21,7 +21,7 @@ Reporter.prototype.toJSON = function(object) {
Reporter.prototype.test = function (result, message) {
this.total++;
if (result) {
if (result) {
this.passes++;
iconElement = document.getElementById('icons');
iconElement.appendChild(createElement('img', {src: '../images/go-16.png'}));
@ -62,8 +62,12 @@ var testMatchersComparisons = function () {
reporter.test(!expected.toEqual(null),
'expect({foo:\'bar\'}).toEqual(null) returned true');
var functionA = function () { return 'hi'; };
var functionB = function () { return 'hi'; };
var functionA = function () {
return 'hi';
};
var functionB = function () {
return 'hi';
};
expected = new Jasmine.Matchers({foo:functionA});
reporter.test(expected.toEqual({foo:functionB}),
'expect({foo: function () { return \'hi\' };})' +
@ -78,11 +82,11 @@ var testMatchersComparisons = function () {
var nodeB = document.createElement('div');
expected = new Jasmine.Matchers(nodeA);
reporter.test((expected.toEqual(nodeA)),
'expect(nodeA).toEqual(nodeA) returned false');
'expect(nodeA).toEqual(nodeA) returned false');
expected = new Jasmine.Matchers(nodeA);
reporter.test(!(expected.toEqual(nodeB)),
'expect(nodeA).toEqual(nodeB) returned true');
'expect(nodeA).toEqual(nodeB) returned true');
expected = new Jasmine.Matchers(true);
@ -233,12 +237,12 @@ var testMatchersComparisons = function () {
reporter.test(expected.toEqual(["foo", Jasmine.any(String)]),
'expect(["foo", "goo"]).toEqual(["foo", Jasmine.any(String)]) should return true');
expected = new Jasmine.Matchers(function () {});
expected = new Jasmine.Matchers(function () {
});
reporter.test(expected.toEqual(Jasmine.any(Function)),
'expect(function () {}).toEqual(Jasmine.any(Function)) should return true');
expected = new Jasmine.Matchers({foo: "bar", baz: undefined});
reporter.test(expected.toEqual({foo: "bar", baz: undefined}),
'expect({foo: "bar", baz: undefined}).toEqual({foo: "bar", baz: undefined}) should return true');
@ -1257,7 +1261,8 @@ var testSpecSpy = function () {
});
it('should be able to reset a spy', function() {
var TestClass = { someFunction: function() {} };
var TestClass = { someFunction: function() {
} };
this.spyOn(TestClass, 'someFunction');
expect(TestClass.someFunction).wasNotCalled();
@ -1628,12 +1633,14 @@ var testJSONReporterWithDOM = function () {
Jasmine.getEnv().reporter = Jasmine.Reporters.JSONtoDOM('json_reporter_results');
runner.execute();
var expectedJSONString = '{"totalCount":1,"passedCount":1,"failedCount":0,"results":[{"totalCount":1,"passedCount":1,"failedCount":0,"results":[{"totalCount":1,"passedCount":1,"failedCount":0,"results":[{"passed":true,"message":"Passed."}],"description":"should be a test"}],"description":"Suite for JSON Reporter/DOM"}],"description":"All Jasmine Suites"}';
//innerText not supported in firefox.
reporter.test((document.getElementById('json_reporter_results').innerHTML == expectedJSONString),
'JSON Reporter with DOM did not write the expected report to the DOM, got:' + document.getElementById('json_reporter_results').innerHTML);
var expectedJsonString = '{"totalCount":1,"passedCount":1,"failedCount":0,"results":[{"totalCount":1,"passedCount":1,"failedCount":0,"results":[{"totalCount":1,"passedCount":1,"failedCount":0,"results":[{"passed":true,"message":"Passed."}],"description":"should be a test"}],"description":"Suite for JSON Reporter/DOM"}],"description":"All Jasmine Suites"}';
//this statement makes sure we have a string that is the same across different DOM implementations.
var actualJsonString = document.getElementById('json_reporter_results').innerHTML.replace(/"/g, '"');
reporter.test((actualJsonString == expectedJsonString),
'JSON Reporter with DOM did not write the expected report to the DOM, got:<br /><br />' + actualJsonString + '<br /><br />expected<br /><br />' + expectedJsonString);
};
var testHandlesBlankSpecs = function () {
Jasmine.currentEnv_ = new Jasmine.Env();
var runner = Runner();