I used FUSE Admin app on my project – http://fuse-angular-material.withinpixels.com/apps/dashboards/project.
I already checked other samples and even run this code on a different project and works just fine. IT’s just that I cannot inject the service, controller etc. on ‘beforeEach inject’, thus I cannot cont. my test.
I don’t know what’s wrong or did I miss something (dependencies? not sure) while running this on FUSE. Do you have any idea?
Here’s my code.
SERVICE (the service returns a list of array)
(function () {
'use strict';
angular
.module('app.admin.users', [])
.config(config)
.service('adminUserService', service);
function service(msApi) {
return {
adminUserList: function () {
return msApi.resolve('admin.users.list@query');
}
};
}
function config(msApiProvider) {
// calling the API (used dummy data)
msApiProvider.register('admin.users.list',['app/data/admin/users/users.json']);
}
})();
UNIT TEST
var oDataService;
var adminUserService;
describe('unit test ----------------------------', function () {
beforeEach(module('app.admin.users'));
beforeEach(function () {
inject(function ($injector) {
adminUserService = $injector.get('adminUserService');
oDataService = adminUserService.adminUserList();
});
});
it("is registered with the module.", function () {
expect(oDataService).not.toBe(null);
});
});
Source: AngularJS
from Angular Questions https://angularquestions.com/2017/09/28/cannot-call-beforeeach-inject-on-angularjs-fuse-admin-unit-testing-using-karma/
via @lzomedia #developer #freelance #web
No comments:
Post a Comment