I am trying to write a test for an angular filter I've created.
The filter needs to get some data from a service which calls a webapi.
I've mocked the service, mockContentService, and it simply returns a resolved promise with nothing in at minute, however my test fails with timeout, 'timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.'. My question is where would I need to declare the callback? Normally would be
it('should return Yes', function (done) {
...
...
done();
}
but I am puzzled because in my test I am calling inject as so
it('should return Yes', inject(function (boolToYesNoFilter) {
can anyone advise where I would add the done callback and then call?
beforeEach(function($q) {
mockUtils = {
getText: function(region) {
if (region === 'affirmativedisplayvalue') {
return 'Yes';
} else if (region === 'negativedisplayvalue') {
return 'No';
} else {
return 'Unknown';
}
}
};
mockContentService = {
getContentByGroup: function(groupName) {
var deferred = $q.promise;
return deferred.resolve();
}
};
describe('when input is boolean true', function () {
it('should return Yes', inject(function (boolToYesNoFilter) {
// Arrange.
var input = true;
// Assert.
assert.equal(boolToYesNoFilter(input), 'Yes');
done();
}));
});
Aucun commentaire:
Enregistrer un commentaire