Updated unit test
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-03-05 14:49:41 +01:00
parent 30d5370080
commit fddc8e7ed1
2 changed files with 12 additions and 8 deletions

View File

@ -3,14 +3,19 @@ import './index.js';
describe('Item Component vnClaimDescriptor', () => { describe('Item Component vnClaimDescriptor', () => {
let $httpParamSerializer; let $httpParamSerializer;
let $httpBackend; let $httpBackend;
let $element;
let $scope;
let controller; let controller;
beforeEach(ngModule('claim')); beforeEach(ngModule('claim'));
beforeEach(angular.mock.inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => { beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
$httpParamSerializer = _$httpParamSerializer_; $httpParamSerializer = _$httpParamSerializer_;
controller = $componentController('vnClaimDescriptor'); $scope = $rootScope.$new();
$element = angular.element('<vn-claim-descriptor></vn-claim-descriptor>');
controller = $componentController('vnClaimDescriptor', {$element, $scope});
controller.claim = {id: 2, clientFk: 101, client: {email: 'client@email'}}; controller.claim = {id: 2, clientFk: 101, client: {email: 'client@email'}};
})); }));
@ -31,13 +36,13 @@ describe('Item Component vnClaimDescriptor', () => {
describe('confirmPickupOrder()', () => { describe('confirmPickupOrder()', () => {
it('should call confirmPickupOrder.show()', () => { it('should call confirmPickupOrder.show()', () => {
controller.$scope.confirmPickupOrder = { controller.$.confirmPickupOrder = {
show: jasmine.createSpy('show') show: jasmine.createSpy('show')
}; };
controller.claim = {id: 2}; controller.claim = {id: 2};
controller.confirmPickupOrder(); controller.confirmPickupOrder();
expect(controller.$scope.confirmPickupOrder.show).toHaveBeenCalledWith(); expect(controller.$.confirmPickupOrder.show).toHaveBeenCalledWith();
}); });
}); });
@ -63,13 +68,13 @@ describe('Item Component vnClaimDescriptor', () => {
describe('confirmDeleteClaim()', () => { describe('confirmDeleteClaim()', () => {
it('should call confirmDeleteClaim.show()', () => { it('should call confirmDeleteClaim.show()', () => {
controller.$scope.confirmDeleteClaim = { controller.$.confirmDeleteClaim = {
show: jasmine.createSpy('show') show: jasmine.createSpy('show')
}; };
controller.claim = {id: 2}; controller.claim = {id: 2};
controller.confirmDeleteClaim(); controller.confirmDeleteClaim();
expect(controller.$scope.confirmDeleteClaim.show).toHaveBeenCalledWith(); expect(controller.$.confirmDeleteClaim.show).toHaveBeenCalledWith();
}); });
}); });

View File

@ -1,6 +1,5 @@
import './index.js'; import './index.js';
describe('Component vnWorkerTimeControl', () => { describe('Component vnWorkerTimeControl', () => {
let $httpBackend; let $httpBackend;
let $scope; let $scope;
@ -9,7 +8,7 @@ describe('Component vnWorkerTimeControl', () => {
beforeEach(ngModule('worker')); beforeEach(ngModule('worker'));
beforeEach(angular.mock.inject(($componentController, $compile, $rootScope, $stateParams, _$httpBackend_) => { beforeEach(angular.mock.inject(($componentController, $rootScope, $stateParams, _$httpBackend_) => {
$stateParams.id = 1; $stateParams.id = 1;
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
$scope = $rootScope.$new(); $scope = $rootScope.$new();