I have simple filter which depends of moment.js:
app.filter('fromNow', function() {
return function(date) {
return moment(date).fromNow();
}
});
Have can i write unit test of this in jasmine ?
EDIT: now i have
ReferenceError: moment is not defined
when write like that:
describe("fromNow filter", function(){
var moment;
beforeEach(function(){
module('reports');
moment = jasmine.createSpy();
});
it("should output string when input string",
inject(function(fromNowFilter) {
fromNowFilter("string");
}));
})
You need to add moment.js to the testing framework. I had the same problem and fixed adding the following line to my karma.conf.js
...files: [
....
'app/bower_components/moment/moment.js',
....
],
.....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With