Check the exception message in all Realm tests which assert an exception is thrown

This commit is contained in:
Thomas Goyne 2017-09-14 15:50:11 -07:00
parent 4ad75c9546
commit 53ca09839e
2 changed files with 238 additions and 296 deletions

View File

@ -120,6 +120,23 @@ module.exports = {
} }
}, },
assertThrowsContaining: function(func, expectedMessage) {
var caught = false;
try {
func();
}
catch (e) {
caught = true;
if (!e.message.includes(expectedMessage)) {
throw new TestFailureError(`Expected exception "${expectedMessage}" not thrown - instead caught: "${e}"`);
}
}
if (!caught) {
throw new TestFailureError(`Expected exception "${expectedMessage}" not thrown`);
}
},
assertTrue: function(condition, errorMessage) { assertTrue: function(condition, errorMessage) {
if (!condition) { if (!condition) {
throw new TestFailureError(errorMessage || `Condition ${condition} expected to be true`); throw new TestFailureError(errorMessage || `Condition ${condition} expected to be true`);

File diff suppressed because it is too large Load Diff