mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 15:24:43 +00:00
added MatcherSpec
This commit is contained in:
parent
26ed747588
commit
6d0eeda1e2
2 changed files with 30 additions and 1 deletions
|
|
@ -15,7 +15,6 @@ Matcher.addMatcher = function(name, matcher) {
|
||||||
done();
|
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');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue