From f813d052aa6c471d2283a4ee956272bf7012c5ed Mon Sep 17 00:00:00 2001 From: Carlos Date: Thu, 31 Aug 2017 08:53:17 +0200 Subject: [PATCH] unit test for address-create.js and address-edit.js --- .../src/address-create/address-create.spec.js | 63 ++++++------------- .../src/address-edit/address-edit.spec.js | 24 +++++++ 2 files changed, 43 insertions(+), 44 deletions(-) create mode 100644 client/client/src/address-edit/address-edit.spec.js diff --git a/client/client/src/address-create/address-create.spec.js b/client/client/src/address-create/address-create.spec.js index 3cf93e34e..7658e7972 100644 --- a/client/client/src/address-create/address-create.spec.js +++ b/client/client/src/address-create/address-create.spec.js @@ -1,48 +1,23 @@ -//TEST PENDING DUE TO MISSING TRIGGER ON FORM SUBMIT. +import './address-create.js'; -// import './address-create.js'; +describe('Component vnAddressCreate', () => { + let $componentController; + let $state; -// describe('Component vnAddressCreate', () => { -// let $componentController; -// let $state; -// let $scope; -// let $httpBackend; -// let vnApp; + beforeEach(() => { + angular.mock.module('client'); + }); -// beforeEach(() => { -// angular.mock.module('client'); -// }); - -// beforeEach(angular.mock.inject(function(_$componentController_, $rootScope, _$httpBackend_,_$state_, _vnApp_) { -// $componentController = _$componentController_; -// $scope = $rootScope.$new(); -// $httpBackend = _$httpBackend_; -// $state = _$state_; -// vnApp = _vnApp_; -// spyOn(vnApp, 'showError'); -// })); - -// it('should request to update the password', function() { -// let controller = $componentController('vnAddressCreate', {$httpBackend: $httpBackend, $scope: $scope, $state: $state}); -// controller.address = { -// agencyFk: 23, -// city: "Valencia", -// clientFk: 3, -// consignee: "sd", -// enabled: false, -// id: 22490, -// mobile: "123456789", -// phone: "98765432", -// postcode: "12345", -// provinceFk: 63, -// street: "a" -// }; -// $httpBackend.when('PATCH', '/client/api/Addresses/3').respond('done'); -// $httpBackend.expectPATCH('/client/api/Addresses/3', { -// clientFk: 3, -// enabled: true -// }); -// $httpBackend.flush(); -// }); -// }); + beforeEach(angular.mock.inject(function(_$componentController_, _$state_) { + $componentController = _$componentController_; + $state = _$state_; + $state.params.id = '1234'; + })); + it('should define and set address property', () => { + let controller = $componentController('vnAddressCreate', {$state: $state}); + expect(controller.address).toBeDefined(); + expect(controller.address.clientFk).toBe(1234); + expect(controller.address.enabled).toBe(true); + }); +}); diff --git a/client/client/src/address-edit/address-edit.spec.js b/client/client/src/address-edit/address-edit.spec.js new file mode 100644 index 000000000..124df665d --- /dev/null +++ b/client/client/src/address-edit/address-edit.spec.js @@ -0,0 +1,24 @@ +import './address-edit.js'; + +describe('Component vnAddressEdit', () => { + let $componentController; + let $scope; + let $state; + + beforeEach(() => { + angular.mock.module('client'); + }); + + beforeEach(angular.mock.inject(function(_$componentController_, $rootScope, _$state_) { + $componentController = _$componentController_; + $scope = $scope; + $state = _$state_; + $state.params.addressId = '1234'; + })); + + it('should define and set address property', () => { + let controller = $componentController('vnAddressEdit', {$state: $state}); + expect(controller.address).toBeDefined(); + expect(controller.address.id).toBe(1234); + }); +});