#512 /main-menu/main-menu.js Front unit test

This commit is contained in:
Carlos Jimenez 2018-08-21 09:03:51 +02:00
parent d2eaa62461
commit 2b4959ce36
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
import './main-menu.js';
describe('Component vnMainMenu', () => {
let $httpBackend;
let controller;
beforeEach(() => {
angular.mock.module('salix');
});
beforeEach(angular.mock.inject((_$componentController_, _$httpBackend_) => {
let modulesFactory = {getModules: () => {}};
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
controller = _$componentController_('vnMainMenu', {modulesFactory: modulesFactory});
}));
describe('getCurrentUserName()', () => {
it(`should set the user name property in the controller`, () => {
$httpBackend.when('GET', `/auth/api/Accounts/getCurrentUserName`).respond('Batman');
$httpBackend.expect('GET', `/auth/api/Accounts/getCurrentUserName`);
controller.getCurrentUserName();
$httpBackend.flush();
expect(controller.$.currentUserName).toEqual('Batman');
});
});
});