From 9c0613e8e7900df1f1f113b271e770c4d9f1c8b6 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Tue, 12 Feb 2019 14:40:13 +0100 Subject: [PATCH] #1127 --- front/core/lib/specs/module-loader.spec.js | 14 -- .../front/descriptor-popover/index.spec.js | 201 +++++++++--------- modules/ticket/front/descriptor/index.spec.js | 6 +- 3 files changed, 102 insertions(+), 119 deletions(-) diff --git a/front/core/lib/specs/module-loader.spec.js b/front/core/lib/specs/module-loader.spec.js index c8def1634..bc705f40f 100644 --- a/front/core/lib/specs/module-loader.spec.js +++ b/front/core/lib/specs/module-loader.spec.js @@ -28,19 +28,5 @@ describe('factory vnModuleLoader', () => { expect(result).toEqual(jasmine.any(Promise)); }); - - it('should return an error if the module wasnt loaded', done => { - vnModuleLoader._loaded.myModule = false; - - vnModuleLoader.load('myModule', {myValidations: () => {}}) - .then(() => { - done.fail('this must fail'); - }) - .catch(error => { - expect(error.toString()).toEqual(`Error: Module dependency loop detected: myModule`); - done(); - }); - $scope.$apply(); - }); }); }); diff --git a/modules/ticket/front/descriptor-popover/index.spec.js b/modules/ticket/front/descriptor-popover/index.spec.js index 9e3d39e4b..499ca5413 100644 --- a/modules/ticket/front/descriptor-popover/index.spec.js +++ b/modules/ticket/front/descriptor-popover/index.spec.js @@ -1,126 +1,125 @@ import './index.js'; -describe('Item', () => { - describe('Component vnTicketDescriptorPopover', () => { - let $httpBackend; - let $scope; - let controller; - let $element; - let $timeout; +describe('ticket Component vnTicketDescriptorPopover', () => { + let $httpBackend; + let $scope; + let controller; + let $element; + let $timeout; - beforeEach(ngModule('item')); + beforeEach(ngModule('ticket')); - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$timeout_) => { - $httpBackend = _$httpBackend_; - $timeout = _$timeout_; - $element = angular.element(`
`); - $scope = $rootScope.$new(); - $scope.popover = {relocate: () => {}, show: () => {}}; - controller = $componentController('vnTicketDescriptorPopover', {$scope, $element}); - })); + beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$timeout_) => { + $httpBackend = _$httpBackend_; + $timeout = _$timeout_; + $element = angular.element(`
`); + $scope = $rootScope.$new(); + $scope.popover = {relocate: () => {}, show: () => {}}; + controller = $componentController('vnTicketDescriptorPopover', {$scope, $element}); + })); - describe('ticketFk()', () => { - it(`should not apply any changes if the received id is the same stored in _ticketFk`, () => { - controller.ticket = 'I exist!'; - controller._ticketFk = 1; - spyOn(controller, 'getCard'); - controller.ticketFk = 1; + describe('ticketFk()', () => { + it(`should not apply any changes if the received id is the same stored in _ticketFk`, () => { + controller.ticket = 'I exist!'; + controller._ticketFk = 1; + spyOn(controller, 'getCard'); + controller.ticketFk = 1; - expect(controller.ticket).toEqual('I exist!'); - expect(controller._ticketFk).toEqual(1); - expect(controller.getCard).not.toHaveBeenCalled(); - }); - - it(`should set the received id into _ticketFk, set the ticket to null and then call getCard()`, () => { - controller.ticket = `Please don't`; - controller._ticketFk = 1; - spyOn(controller, 'getCard'); - controller.ticketFk = 999; - - expect(controller.ticket).toBeNull(); - expect(controller._ticketFk).toEqual(999); - expect(controller.getCard).toHaveBeenCalledWith(); - }); + expect(controller.ticket).toEqual('I exist!'); + expect(controller._ticketFk).toEqual(1); + expect(controller.getCard).not.toHaveBeenCalled(); }); - describe('ticket()', () => { - it(`should save the ticket into _ticket and then call relocate()`, () => { - spyOn(controller.$.popover, 'relocate'); - controller.ticket = `i'm the ticket!`; - $timeout.flush(); + it(`should set the received id into _ticketFk, set the ticket to null and then call getCard()`, () => { + controller.ticket = `Please don't`; + controller._ticketFk = 1; + spyOn(controller, 'getCard'); + controller.ticketFk = 999; - expect(controller._ticket).toEqual(`i'm the ticket!`); - expect(controller.$.popover.relocate).toHaveBeenCalledWith(); - }); + expect(controller.ticket).toBeNull(); + expect(controller._ticketFk).toEqual(999); + expect(controller.getCard).toHaveBeenCalledWith(); }); + }); - describe('show()', () => { - it(`should call the show()`, () => { - spyOn(controller.$.popover, 'show'); - controller.show(); + describe('ticket()', () => { + it(`should save the ticket into _ticket and then call relocate()`, () => { + spyOn(controller.$.popover, 'relocate'); + controller.ticket = `i'm the ticket!`; + $timeout.flush(); - expect(controller.$.popover.show).toHaveBeenCalledWith(); - }); + expect(controller._ticket).toEqual(`i'm the ticket!`); + expect(controller.$.popover.relocate).toHaveBeenCalledWith(); }); + }); - describe('getCard()', () => { - it(`should perform a get query to store the ticket data into the controller`, () => { - controller.ticketFk = 1; - controller.canceler = null; - let response = {}; + describe('show()', () => { + it(`should call the show()`, () => { + spyOn(controller.$.popover, 'show'); + controller.show(); - let filter = { - include: [ - { - relation: 'warehouse', - scope: { - fields: ['name'] - } - }, - { - relation: 'agencyMode', - scope: { - fields: ['name'] - } - }, - { - relation: 'client', - scope: { - fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'], - include: { - relation: 'salesPerson', - scope: { - fields: ['userFk'], - include: { - relation: 'user', - scope: { - fields: ['nickname'] - } + expect(controller.$.popover.show).toHaveBeenCalledWith(); + }); + }); + + describe('getCard()', () => { + it(`should perform a get query to store the ticket data into the controller`, () => { + controller.ticketFk = 1; + controller.canceler = null; + let response = {}; + + let filter = { + include: [ + { + relation: 'warehouse', + scope: { + fields: ['name'] + } + }, + { + relation: 'agencyMode', + scope: { + fields: ['name'] + } + }, + { + relation: 'client', + scope: { + fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'], + include: { + relation: 'salesPerson', + scope: { + fields: ['userFk'], + include: { + relation: 'user', + scope: { + fields: ['nickname'] } } } } - }, - { - relation: 'state', - scope: { - fields: ['stateFk'], - include: { - relation: 'state', - fields: ['id', 'name'], - } + } + }, + { + relation: 'state', + scope: { + fields: ['stateFk'], + include: { + relation: 'state', + fields: ['id', 'name'], } } - ] - }; - let json = encodeURIComponent(JSON.stringify(filter)); - $httpBackend.when('GET', `/ticket/api/Tickets/${controller._ticketFk}?filter=${json}`).respond(response); - $httpBackend.expect('GET', `/ticket/api/Tickets/${controller._ticketFk}?filter=${json}`); - controller.getCard(); - $httpBackend.flush(); + } + ] + }; + let json = encodeURIComponent(JSON.stringify(filter)); + $httpBackend.when('GET', `/ticket/api/Tickets/${controller._ticketFk}?filter=${json}`).respond(response); + $httpBackend.expect('GET', `/ticket/api/Tickets/${controller._ticketFk}?filter=${json}`); + controller.getCard(); + $httpBackend.flush(); - expect(controller.ticket).toEqual(response); - }); + expect(controller.ticket).toEqual(response); }); }); }); + diff --git a/modules/ticket/front/descriptor/index.spec.js b/modules/ticket/front/descriptor/index.spec.js index 51293f462..2c2359299 100644 --- a/modules/ticket/front/descriptor/index.spec.js +++ b/modules/ticket/front/descriptor/index.spec.js @@ -1,12 +1,10 @@ import './index.js'; -describe('Item Component vnTicketDescriptor', () => { +describe('Ticket Component vnTicketDescriptor', () => { let $httpBackend; let controller; - beforeEach(() => { - ngModule('item'); - }); + beforeEach(ngModule('ticket')); beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { $httpBackend = _$httpBackend_;