@@ -1,6 +1,6 @@
|
||||
describe('toThrowError', function() {
|
||||
it('throws an error when the actual is not a function', function() {
|
||||
const matcher = jasmineUnderTest.matchers.toThrowError();
|
||||
const matcher = privateUnderTest.matchers.toThrowError();
|
||||
|
||||
expect(function() {
|
||||
matcher.compare({});
|
||||
@@ -8,7 +8,7 @@ describe('toThrowError', function() {
|
||||
});
|
||||
|
||||
it('throws an error when the expected is not an Error, string, or RegExp', function() {
|
||||
const matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
||||
fn = function() {
|
||||
throw new Error('foo');
|
||||
};
|
||||
@@ -19,7 +19,7 @@ describe('toThrowError', function() {
|
||||
});
|
||||
|
||||
it('throws an error when the expected error type is not an Error', function() {
|
||||
const matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
||||
fn = function() {
|
||||
throw new Error('foo');
|
||||
};
|
||||
@@ -30,7 +30,7 @@ describe('toThrowError', function() {
|
||||
});
|
||||
|
||||
it('throws an error when the expected error message is not a string or RegExp', function() {
|
||||
const matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
||||
fn = function() {
|
||||
throw new Error('foo');
|
||||
};
|
||||
@@ -41,7 +41,7 @@ describe('toThrowError', function() {
|
||||
});
|
||||
|
||||
it('fails if actual does not throw at all', function() {
|
||||
const matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
||||
fn = function() {
|
||||
return true;
|
||||
};
|
||||
@@ -53,8 +53,8 @@ describe('toThrowError', function() {
|
||||
});
|
||||
|
||||
it('fails if thrown is not an instanceof Error', function() {
|
||||
const matcher = jasmineUnderTest.matchers.toThrowError({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
const matcher = privateUnderTest.matchers.toThrowError({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {
|
||||
throw 4;
|
||||
@@ -85,7 +85,7 @@ describe('toThrowError', function() {
|
||||
pending('This test only runs in browsers.');
|
||||
}
|
||||
|
||||
const matcher = jasmineUnderTest.matchers.toThrowError();
|
||||
const matcher = privateUnderTest.matchers.toThrowError();
|
||||
iframe = document.body.appendChild(document.createElement('iframe'));
|
||||
iframe.src = 'about:blank';
|
||||
const iframeDocument = iframe.contentWindow.document;
|
||||
@@ -103,8 +103,8 @@ describe('toThrowError', function() {
|
||||
});
|
||||
|
||||
it('fails with the correct message if thrown is a falsy value', function() {
|
||||
const matcher = jasmineUnderTest.matchers.toThrowError({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
const matcher = privateUnderTest.matchers.toThrowError({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {
|
||||
throw undefined;
|
||||
@@ -118,7 +118,7 @@ describe('toThrowError', function() {
|
||||
});
|
||||
|
||||
it('passes if thrown is a type of Error, but there is no expected error', function() {
|
||||
const matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
||||
fn = function() {
|
||||
throw new TypeError();
|
||||
};
|
||||
@@ -132,8 +132,8 @@ describe('toThrowError', function() {
|
||||
});
|
||||
|
||||
it('passes if thrown is an Error and the expected is the same message', function() {
|
||||
const matcher = jasmineUnderTest.matchers.toThrowError({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
const matcher = privateUnderTest.matchers.toThrowError({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {
|
||||
throw new Error('foo');
|
||||
@@ -148,8 +148,8 @@ describe('toThrowError', function() {
|
||||
});
|
||||
|
||||
it('fails if thrown is an Error and the expected is not the same message', function() {
|
||||
const matcher = jasmineUnderTest.matchers.toThrowError({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
const matcher = privateUnderTest.matchers.toThrowError({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {
|
||||
throw new Error('foo');
|
||||
@@ -164,8 +164,8 @@ describe('toThrowError', function() {
|
||||
});
|
||||
|
||||
it('passes if thrown is an Error and the expected is a RegExp that matches the message', function() {
|
||||
const matcher = jasmineUnderTest.matchers.toThrowError({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
const matcher = privateUnderTest.matchers.toThrowError({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {
|
||||
throw new Error('a long message');
|
||||
@@ -180,8 +180,8 @@ describe('toThrowError', function() {
|
||||
});
|
||||
|
||||
it('fails if thrown is an Error and the expected is a RegExp that does not match the message', function() {
|
||||
const matcher = jasmineUnderTest.matchers.toThrowError({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
const matcher = privateUnderTest.matchers.toThrowError({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
fn = function() {
|
||||
throw new Error('a long message');
|
||||
@@ -196,7 +196,7 @@ describe('toThrowError', function() {
|
||||
});
|
||||
|
||||
it('passes if thrown is an Error and the expected the same Error', function() {
|
||||
const matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
||||
fn = function() {
|
||||
throw new Error();
|
||||
};
|
||||
@@ -208,7 +208,7 @@ describe('toThrowError', function() {
|
||||
});
|
||||
|
||||
it('passes if thrown is a custom error that takes arguments and the expected is the same error', function() {
|
||||
const matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
||||
CustomError = function CustomError(arg) {
|
||||
arg.x;
|
||||
},
|
||||
@@ -227,7 +227,7 @@ describe('toThrowError', function() {
|
||||
});
|
||||
|
||||
it('fails if thrown is an Error and the expected is a different Error', function() {
|
||||
const matcher = jasmineUnderTest.matchers.toThrowError(),
|
||||
const matcher = privateUnderTest.matchers.toThrowError(),
|
||||
fn = function() {
|
||||
throw new Error();
|
||||
};
|
||||
@@ -243,9 +243,9 @@ describe('toThrowError', function() {
|
||||
it('passes if thrown is a type of Error and it is equal to the expected Error and message', function() {
|
||||
const matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
|
||||
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
|
||||
fn = function() {
|
||||
throw new TypeError('foo');
|
||||
};
|
||||
@@ -261,9 +261,9 @@ describe('toThrowError', function() {
|
||||
it('passes if thrown is a custom error that takes arguments and it is equal to the expected custom error and message', function() {
|
||||
const matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
|
||||
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
|
||||
CustomError = function CustomError(arg) {
|
||||
this.message = arg.message;
|
||||
},
|
||||
@@ -285,9 +285,9 @@ describe('toThrowError', function() {
|
||||
it('fails if thrown is a type of Error and the expected is a different Error', function() {
|
||||
const matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
|
||||
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
|
||||
fn = function() {
|
||||
throw new TypeError('foo');
|
||||
};
|
||||
@@ -305,9 +305,9 @@ describe('toThrowError', function() {
|
||||
it('fails if thrown is a type of Error and the expected is a different Error', function() {
|
||||
const matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
|
||||
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
|
||||
fn = function() {
|
||||
throw new TypeError('foo');
|
||||
};
|
||||
@@ -324,9 +324,9 @@ describe('toThrowError', function() {
|
||||
it('passes if thrown is a type of Error and has the same type as the expected Error and the message matches the expected message', function() {
|
||||
const matchersUtil = {
|
||||
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
},
|
||||
matcher = jasmineUnderTest.matchers.toThrowError(matchersUtil),
|
||||
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
|
||||
fn = function() {
|
||||
throw new TypeError('foo');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user