mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-21 00:40:24 +00:00
21 lines
584 B
JavaScript
21 lines
584 B
JavaScript
function Matcher(scope, future, logger) {
|
|
var self = scope.$scenario = this;
|
|
this.logger = logger;
|
|
this.future = future;
|
|
}
|
|
|
|
Matcher.addMatcher = function(name, matcher) {
|
|
Matcher.prototype[name] = function(expected) {
|
|
var future = this.future;
|
|
$scenario.addFuture(
|
|
'expect ' + future.name + ' ' + name + ' ' + expected,
|
|
function(done){
|
|
if (!matcher(future.value, expected))
|
|
throw "Expected " + expected + ' but was ' + future.value;
|
|
done();
|
|
}
|
|
);
|
|
};
|
|
};
|
|
|
|
Matcher.addMatcher('toEqual', function(a,b) { return a == b; });
|