I am running into some challenges unit testing $log.
I wanted to try a simple test that took the value I injected and tested. I am not hooking the spec up to a restful call yet. I am using angular mocks. Here are my before each statements. I have the module defined through angular mocks. Some of what I have been testing has came from this blog http://ift.tt/1HVdfF0.
In my devDependencies
"angular": "^1.5.0",
"angular-mocks": "^1.5.0",
So I know the versions of angular and mocks are matched up.
beforeEach(function () {
angular.mock.module('ha.module.utility');
angular.mock.inject(function ($httpBackend, haHttpService) {
http = $httpBackend;
service = haHttpService;
});
});
beforeEach(inject(function (_$log_) {
$log = _$log_;
}));
afterEach(function () {
http.flush();
http.verifyNoOutstandingExpectation();
http.verifyNoOutstandingRequest();
});
The test itself is just making sure I have $log working.
it('should call logs', function () {
$log.info('it worked');
expect($log.info.logs).toContain(['it worked']);
});
However I am returning
ReferenceError: inject is not defined
Aucun commentaire:
Enregistrer un commentaire