mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-05-19 12:52:25 +08:00
added MatcherSpec
This commit is contained in:
@@ -15,7 +15,6 @@ Matcher.addMatcher = function(name, matcher) {
|
||||
done();
|
||||
}
|
||||
);
|
||||
dump('future added');
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
30
test/scenario/MatcherSpec.js
Normal file
30
test/scenario/MatcherSpec.js
Normal file
@@ -0,0 +1,30 @@
|
||||
describe('Matcher', function () {
|
||||
function executeFutures() {
|
||||
for(var i in $scenario.currentSpec.futures) {
|
||||
var future = $scenario.currentSpec.futures[i];
|
||||
future.behavior.call({}, function(value) { future.fulfill(value); });
|
||||
}
|
||||
}
|
||||
var matcher;
|
||||
beforeEach(function() {
|
||||
setUpContext();
|
||||
var future = $scenario.addFuture('Calculate first future', function(done) {
|
||||
done(123);
|
||||
});
|
||||
matcher = new Matcher(this, future);
|
||||
|
||||
});
|
||||
it('should correctly match toEqual', function() {
|
||||
matcher.toEqual(123);
|
||||
executeFutures();
|
||||
});
|
||||
it('should throw an error when incorrect match toEqual', function() {
|
||||
matcher.toEqual(456);
|
||||
try {
|
||||
executeFutures();
|
||||
fail();
|
||||
} catch (e) {
|
||||
expect(e).toEqual('Expected 456 but was 123');
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user