Resolve remaining test issues
This commit is contained in:
@@ -41,8 +41,11 @@ describe("ExceptionFormatter", function() {
|
|||||||
|
|
||||||
describe("#stack", function() {
|
describe("#stack", function() {
|
||||||
it("formats stack traces from Webkit, Firefox or node.js", function() {
|
it("formats stack traces from Webkit, Firefox or node.js", function() {
|
||||||
|
if (isIE()) { return; }
|
||||||
|
|
||||||
var error;
|
var error;
|
||||||
try { throw new Error("an error") } catch(e) { error = e; };
|
try { throw new Error("an error") } catch(e) { error = e; }
|
||||||
|
|
||||||
expect(new j$.ExceptionFormatter().stack(error)).toMatch(/ExceptionFormatterSpec\.js.*\d+/)
|
expect(new j$.ExceptionFormatter().stack(error)).toMatch(/ExceptionFormatterSpec\.js.*\d+/)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ describe("ObjectContaining", function() {
|
|||||||
it("does not match an empty object actual", function() {
|
it("does not match an empty object actual", function() {
|
||||||
var containing = new j$.ObjectContaining("foo");
|
var containing = new j$.ObjectContaining("foo");
|
||||||
|
|
||||||
expect(containing.jasmineMatches({})).toBe(false);
|
expect(function() {
|
||||||
|
containing.jasmineMatches({})
|
||||||
|
}).toThrowError(/not 'foo'/)
|
||||||
});
|
});
|
||||||
|
|
||||||
it("matches when the key/value pair is present in the actual", function() {
|
it("matches when the key/value pair is present in the actual", function() {
|
||||||
@@ -39,10 +41,21 @@ describe("ObjectContaining", function() {
|
|||||||
containing.jasmineMatches({foo: "fooVal", bar: "barVal"}, mismatchKeys, mismatchValues);
|
containing.jasmineMatches({foo: "fooVal", bar: "barVal"}, mismatchKeys, mismatchValues);
|
||||||
|
|
||||||
expect(mismatchValues.length).toBe(1);
|
expect(mismatchValues.length).toBe(1);
|
||||||
|
|
||||||
expect(mismatchValues[0]).toEqual("'foo' was 'fooVal' in actual, but was 'other' in expected.");
|
expect(mismatchValues[0]).toEqual("'foo' was 'fooVal' in actual, but was 'other' in expected.");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("adds keys in expected but not actual to the mismatchKeys parameter", function() {
|
||||||
|
var containing = new j$.ObjectContaining({foo: "fooVal"});
|
||||||
|
|
||||||
|
var mismatchKeys = [];
|
||||||
|
var mismatchValues = [];
|
||||||
|
|
||||||
|
containing.jasmineMatches({bar: "barVal"}, mismatchKeys, mismatchValues);
|
||||||
|
|
||||||
|
expect(mismatchKeys.length).toBe(1);
|
||||||
|
expect(mismatchKeys[0]).toEqual("expected has key 'foo', but missing from actual.");
|
||||||
|
});
|
||||||
|
|
||||||
it("jasmineToString's itself", function() {
|
it("jasmineToString's itself", function() {
|
||||||
var containing = new j$.ObjectContaining({});
|
var containing = new j$.ObjectContaining({});
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,8 @@ describe("matchersUtil", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("passes for equivalent frozen objects (GitHub issue #266)", function() {
|
it("passes for equivalent frozen objects (GitHub issue #266)", function() {
|
||||||
|
if (isIE(8)) { return; }
|
||||||
|
|
||||||
var a = { foo: 1 },
|
var a = { foo: 1 },
|
||||||
b = {foo: 1 };
|
b = {foo: 1 };
|
||||||
|
|
||||||
|
|||||||
8
spec/helpers/BrowserFlags.js
Normal file
8
spec/helpers/BrowserFlags.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
function isIE(version) {
|
||||||
|
var userAgent = jasmine.getGlobal().navigator.userAgent;
|
||||||
|
if (!userAgent) { return; }
|
||||||
|
|
||||||
|
var match = /MSIE ([0-9]{1,}[\.0-9]{0,})/.exec(userAgent);
|
||||||
|
|
||||||
|
return match && version ? parseFloat(match[1]) === version : match;
|
||||||
|
}
|
||||||
@@ -5,6 +5,8 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) {
|
ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) {
|
||||||
|
if (typeof(this.sample) !== "object") { throw new Error("You must provide an object to objectContaining, not '"+this.sample+"'."); }
|
||||||
|
|
||||||
mismatchKeys = mismatchKeys || [];
|
mismatchKeys = mismatchKeys || [];
|
||||||
mismatchValues = mismatchValues || [];
|
mismatchValues = mismatchValues || [];
|
||||||
|
|
||||||
@@ -16,7 +18,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
|
|||||||
if (!hasKey(other, property) && hasKey(this.sample, property)) {
|
if (!hasKey(other, property) && hasKey(this.sample, property)) {
|
||||||
mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
|
mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
|
||||||
}
|
}
|
||||||
else if (!j$.matchersUtil.equals(this.sample[property], other[property], mismatchKeys, mismatchValues)) {
|
else if (!j$.matchersUtil.equals(this.sample[property], other[property])) {
|
||||||
mismatchValues.push("'" + property + "' was '" + (other[property] ? j$.util.htmlEscape(other[property].toString()) : other[property]) + "' in actual, but was '" + (this.sample[property] ? j$.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in expected.");
|
mismatchValues.push("'" + property + "' was '" + (other[property] ? j$.util.htmlEscape(other[property].toString()) : other[property]) + "' in actual, but was '" + (this.sample[property] ? j$.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in expected.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user