Throw error if you add a custom matcher or equality outside of a runnable

[#66789174]
This commit is contained in:
Christopher Amavisca and Greg Cobb
2014-03-05 14:37:17 -08:00
parent a2ac5ef3b6
commit a9e0112a9b
3 changed files with 59 additions and 0 deletions

View File

@@ -825,4 +825,51 @@ describe("Env integration", function() {
env.execute();
});
it('throws an exception if you try to add a matcher outside of a runnable', function (done) {
var env = new j$.Env(),
obj = {fn: function () {}},
exception;
env.describe("a suite", function () {
try {
env.addMatchers({myMatcher: function(actual,expected){return false;}});
} catch(e) {
exception = e;
}
});
var assertions = function() {
expect(exception.message).toBe('Matchers must be added in a before function or a spec');
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
it('throws an exception if you try to add a custom equality outside of a runnable', function (done) {
var env = new j$.Env(),
obj = {fn: function () {}},
exception;
env.describe("a suite", function () {
try {
env.addCustomEqualityTester(function(first, second) {return true;});
} catch(e) {
exception = e;
}
});
var assertions = function() {
expect(exception.message).toBe('Custom Equalities must be added in a before function or a spec');
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});