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', () => {
let $httpParamSerializer;
let $scope;
let $element;
let $httpBackend;
let $state;
let controller;
@ -37,12 +38,13 @@ describe('Client', () => {
$state.params.id = 101;
$httpBackend = _$httpBackend_;
$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()', () => {
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');
document.body.querySelector = () => {
return {
@ -52,7 +54,7 @@ describe('Client', () => {
};
};
controller.$scope.sampleType.selection = {
controller.$.sampleType.selection = {
hasCompany: false,
code: 'MyReport'
};
@ -74,11 +76,11 @@ describe('Client', () => {
controller.showPreview(event);
$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`, () => {
spyOn(controller.$scope.showPreview, 'show');
spyOn(controller.$.showPreview, 'show');
const element = document.createElement('div');
document.body.querySelector = () => {
return {
@ -88,7 +90,7 @@ describe('Client', () => {
};
};
controller.$scope.sampleType.selection = {
controller.$.sampleType.selection = {
hasCompany: true,
code: 'MyReport'
};
@ -112,7 +114,7 @@ describe('Client', () => {
controller.showPreview(event);
$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`, () => {
spyOn(controller.$state, 'go');
controller.$scope.sampleType.selection = {
controller.$.sampleType.selection = {
hasCompany: false,
code: 'MyReport'
};
@ -154,7 +156,7 @@ describe('Client', () => {
it(`should perform a query (GET) with companyFk param and call go() method`, () => {
spyOn(controller.$state, 'go');
controller.$scope.sampleType.selection = {
controller.$.sampleType.selection = {
hasCompany: true,
code: 'MyReport'
};