From 2b4959ce36412858193cdb9c646f59887497c43d Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Tue, 21 Aug 2018 09:03:51 +0200 Subject: [PATCH] #512 /main-menu/main-menu.js Front unit test --- .../components/main-menu/main-menu.spec.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 client/salix/src/components/main-menu/main-menu.spec.js diff --git a/client/salix/src/components/main-menu/main-menu.spec.js b/client/salix/src/components/main-menu/main-menu.spec.js new file mode 100644 index 0000000000..082e587cbc --- /dev/null +++ b/client/salix/src/components/main-menu/main-menu.spec.js @@ -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'); + }); + }); +});