unit test for address-create.js and address-edit.js

This commit is contained in:
Carlos 2017-08-31 08:53:17 +02:00
parent 0461b3a429
commit f813d052aa
2 changed files with 43 additions and 44 deletions

View File

@ -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);
});
});

View File

@ -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);
});
});