updated unit tests
gitea/salix/1466-print_refactor This commit has test failures Details

This commit is contained in:
Joan Sanchez 2019-11-11 11:23:39 +01:00
parent 0838540789
commit 115156f89d
1 changed files with 11 additions and 9 deletions

View File

@ -4,6 +4,7 @@ describe('Client', () => {
describe('Component vnClientSampleCreate', () => { describe('Component vnClientSampleCreate', () => {
let $httpParamSerializer; let $httpParamSerializer;
let $scope; let $scope;
let $element;
let $httpBackend; let $httpBackend;
let $state; let $state;
let controller; let controller;
@ -37,12 +38,13 @@ describe('Client', () => {
$state.params.id = 101; $state.params.id = 101;
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
$httpParamSerializer = _$httpParamSerializer_; $httpParamSerializer = _$httpParamSerializer_;
controller = $componentController('vnClientSampleCreate', {$scope, $state}); $element = angular.element('<vn-client-sample-create></vn-client-sample-create>');
controller = $componentController('vnClientSampleCreate', {$element, $scope});
})); }));
describe('showPreview()', () => { describe('showPreview()', () => {
it(`should perform a query (GET) and open a sample preview`, () => { it(`should perform a query (GET) and open a sample preview`, () => {
spyOn(controller.$scope.showPreview, 'show'); spyOn(controller.$.showPreview, 'show');
const element = document.createElement('div'); const element = document.createElement('div');
document.body.querySelector = () => { document.body.querySelector = () => {
return { return {
@ -52,7 +54,7 @@ describe('Client', () => {
}; };
}; };
controller.$scope.sampleType.selection = { controller.$.sampleType.selection = {
hasCompany: false, hasCompany: false,
code: 'MyReport' code: 'MyReport'
}; };
@ -74,11 +76,11 @@ describe('Client', () => {
controller.showPreview(event); controller.showPreview(event);
$httpBackend.flush(); $httpBackend.flush();
expect(controller.$scope.showPreview.show).toHaveBeenCalledWith(); expect(controller.$.showPreview.show).toHaveBeenCalledWith();
}); });
it(`should perform a query (GET) with companyFk param and open a sample preview`, () => { it(`should perform a query (GET) with companyFk param and open a sample preview`, () => {
spyOn(controller.$scope.showPreview, 'show'); spyOn(controller.$.showPreview, 'show');
const element = document.createElement('div'); const element = document.createElement('div');
document.body.querySelector = () => { document.body.querySelector = () => {
return { return {
@ -88,7 +90,7 @@ describe('Client', () => {
}; };
}; };
controller.$scope.sampleType.selection = { controller.$.sampleType.selection = {
hasCompany: true, hasCompany: true,
code: 'MyReport' code: 'MyReport'
}; };
@ -112,7 +114,7 @@ describe('Client', () => {
controller.showPreview(event); controller.showPreview(event);
$httpBackend.flush(); $httpBackend.flush();
expect(controller.$scope.showPreview.show).toHaveBeenCalledWith(); expect(controller.$.showPreview.show).toHaveBeenCalledWith();
}); });
}); });
@ -129,7 +131,7 @@ describe('Client', () => {
it(`should perform a query (GET) and call go() method`, () => { it(`should perform a query (GET) and call go() method`, () => {
spyOn(controller.$state, 'go'); spyOn(controller.$state, 'go');
controller.$scope.sampleType.selection = { controller.$.sampleType.selection = {
hasCompany: false, hasCompany: false,
code: 'MyReport' code: 'MyReport'
}; };
@ -154,7 +156,7 @@ describe('Client', () => {
it(`should perform a query (GET) with companyFk param and call go() method`, () => { it(`should perform a query (GET) with companyFk param and call go() method`, () => {
spyOn(controller.$state, 'go'); spyOn(controller.$state, 'go');
controller.$scope.sampleType.selection = { controller.$.sampleType.selection = {
hasCompany: true, hasCompany: true,
code: 'MyReport' code: 'MyReport'
}; };