lundi 28 août 2017

service.$inject generates error in Jasmine test

I have this code:

app.module.js

'use strict';

angular.module('app', ['ui.testing.Modal']);

app.module.js

    'use strict';

angular.module('app').service('AppService', AppService);

AppService.$inject = ['ui.testing.Modal'];

function AppService() {

this.show = function () {
    return "Hello Service!";
}

}

app.service.spec.js

describe('blablabla', function(){

var service;

beforeEach(module('app', 'ui.testing.Modal'));

beforeEach(inject(function(_AppService_) {
    service = _AppService_;
}));

it('blablabla', function() {
    expect(service.show()).toBe("Hello Service!");
});

});

Running the tests...

Error: [$injector:unpr] Unknown provider: ui.components.ModalProvider <- ui.components.Modal <- AppService http://ift.tt/2xsdhr9$injector/unpr?p0=ui.components.ModalProvider%20%3C-%20ui.components.Modal%20%3C-%20AppService in bower_components/angular/angular.js (line 4826) bower_components/angular/angular.js:4826:86 getService@bower_components/angular/angular.js:4981:39

Any ideas? :(

Aucun commentaire:

Enregistrer un commentaire