$httpBackend.when and .expect no longer misused
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2020-07-23 17:10:07 +02:00
parent 4ca004f833
commit 6913f2db72
27 changed files with 43 additions and 76 deletions

View File

@ -91,7 +91,7 @@ describe('claim', () => {
$httpBackend.flush(); $httpBackend.flush();
expect(controller.$.model.refresh).toHaveBeenCalledWith(); expect(controller.$.model.refresh).toHaveBeenCalledWith();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.$.lastTicketsPopover.hide).toHaveBeenCalledWith(); expect(controller.$.lastTicketsPopover.hide).toHaveBeenCalledWith();
}); });
}); });
@ -106,7 +106,7 @@ describe('claim', () => {
$httpBackend.flush(); $httpBackend.flush();
expect(controller.card.reload).toHaveBeenCalledWith(); expect(controller.card.reload).toHaveBeenCalledWith();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
}); });
}); });

View File

@ -80,7 +80,7 @@ describe('claim', () => {
controller.deleteClaimedSale(); controller.deleteClaimedSale();
$httpBackend.flush(); $httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
}); });
}); });
@ -91,7 +91,7 @@ describe('claim', () => {
controller.setClaimedQuantity(1, 1); controller.setClaimedQuantity(1, 1);
$httpBackend.flush(); $httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
}); });
}); });
@ -126,7 +126,7 @@ describe('claim', () => {
expect(controller.calculateTotals).toHaveBeenCalledWith(); expect(controller.calculateTotals).toHaveBeenCalledWith();
expect(controller.clearDiscount).toHaveBeenCalledWith(); expect(controller.clearDiscount).toHaveBeenCalledWith();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.$.editPopover.hide).toHaveBeenCalledWith(); expect(controller.$.editPopover.hide).toHaveBeenCalledWith();
}); });
}); });

View File

@ -20,8 +20,7 @@ describe('Claim', () => {
describe('getSummary()', () => { describe('getSummary()', () => {
it('should perform a query to set summary', () => { it('should perform a query to set summary', () => {
$httpBackend.when('GET', `Claims/1/getSummary`).respond(200, 24); $httpBackend.expect('GET', `Claims/1/getSummary`).respond(200, 24);
$httpBackend.expect('GET', `Claims/1/getSummary`);
controller.getSummary(); controller.getSummary();
$httpBackend.flush(); $httpBackend.flush();

View File

@ -28,8 +28,7 @@ describe('Client', () => {
let data = {defaultAddressFk: address.id}; let data = {defaultAddressFk: address.id};
let expectedResult = {defaultAddressFk: address.id}; let expectedResult = {defaultAddressFk: address.id};
$httpBackend.when('PATCH', `Clients/1`, data).respond(200, expectedResult); $httpBackend.expect('PATCH', `Clients/1`, data).respond(200, expectedResult);
$httpBackend.expect('PATCH', `Clients/1`, data);
controller.setDefault(address); controller.setDefault(address);
$httpBackend.flush(); $httpBackend.flush();

View File

@ -77,8 +77,7 @@ describe('Client', () => {
it('should call the returnDialog method and perform a PATCH query, then call _getClassifications method', () => { it('should call the returnDialog method and perform a PATCH query, then call _getClassifications method', () => {
jest.spyOn(controller, '_getClassifications').mockReturnThis(); jest.spyOn(controller, '_getClassifications').mockReturnThis();
controller.classificationId = 1; controller.classificationId = 1;
$httpBackend.when('PATCH', `CreditClassifications/1`).respond(200); $httpBackend.expect('PATCH', `CreditClassifications/1`).respond(200);
$httpBackend.expect('PATCH', `CreditClassifications/1`);
controller.returnDialog('accept'); controller.returnDialog('accept');
$httpBackend.flush(); $httpBackend.flush();

View File

@ -39,8 +39,7 @@ describe('Client', () => {
where: {code: 'paymentsLaw'} where: {code: 'paymentsLaw'}
}}; }};
let serializedParams = $httpParamSerializer(params); let serializedParams = $httpParamSerializer(params);
$httpBackend.when('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 12, code: 'paymentsLaw'}); $httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 12, code: 'paymentsLaw'});
$httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`);
controller.setDefaultParams(); controller.setDefaultParams();
$httpBackend.flush(); $httpBackend.flush();
@ -63,8 +62,7 @@ describe('Client', () => {
describe('getAllowedContentTypes()', () => { describe('getAllowedContentTypes()', () => {
it('should make an HTTP GET request to get the allowed content types', () => { it('should make an HTTP GET request to get the allowed content types', () => {
const expectedResponse = ['image/png', 'image/jpg']; const expectedResponse = ['image/png', 'image/jpg'];
$httpBackend.when('GET', `clientDms/allowedContentTypes`).respond(expectedResponse); $httpBackend.expect('GET', `clientDms/allowedContentTypes`).respond(expectedResponse);
$httpBackend.expect('GET', `clientDms/allowedContentTypes`);
controller.getAllowedContentTypes(); controller.getAllowedContentTypes();
$httpBackend.flush(); $httpBackend.flush();

View File

@ -45,7 +45,6 @@ describe('Client', () => {
hasFileAttached: false hasFileAttached: false
}; };
$httpBackend.when('GET', `Dms/${dmsId}`).respond(expectedResponse);
$httpBackend.expect('GET', `Dms/${dmsId}`).respond(expectedResponse); $httpBackend.expect('GET', `Dms/${dmsId}`).respond(expectedResponse);
controller.setDefaultParams(); controller.setDefaultParams();
$httpBackend.flush(); $httpBackend.flush();
@ -70,8 +69,7 @@ describe('Client', () => {
describe('getAllowedContentTypes()', () => { describe('getAllowedContentTypes()', () => {
it('should make an HTTP GET request to get the allowed content types', () => { it('should make an HTTP GET request to get the allowed content types', () => {
const expectedResponse = ['image/png', 'image/jpg']; const expectedResponse = ['image/png', 'image/jpg'];
$httpBackend.when('GET', `clientDms/allowedContentTypes`).respond(expectedResponse); $httpBackend.expect('GET', `clientDms/allowedContentTypes`).respond(expectedResponse);
$httpBackend.expect('GET', `clientDms/allowedContentTypes`);
controller.getAllowedContentTypes(); controller.getAllowedContentTypes();
$httpBackend.flush(); $httpBackend.flush();

View File

@ -126,8 +126,7 @@ describe('Client', () => {
describe('onAcceptEt()', () => { describe('onAcceptEt()', () => {
it('should request to patch the propagation of tax status', () => { it('should request to patch the propagation of tax status', () => {
controller.client = {id: 123, isEqualizated: false}; controller.client = {id: 123, isEqualizated: false};
$httpBackend.when('PATCH', `Clients/${controller.client.id}/addressesPropagateRe`, {isEqualizated: controller.client.isEqualizated}).respond('done'); $httpBackend.expectPATCH(`Clients/${controller.client.id}/addressesPropagateRe`, {isEqualizated: controller.client.isEqualizated}).respond('done');
$httpBackend.expectPATCH(`Clients/${controller.client.id}/addressesPropagateRe`, {isEqualizated: controller.client.isEqualizated});
controller.onAcceptEt(); controller.onAcceptEt();
$httpBackend.flush(); $httpBackend.flush();
}); });

View File

@ -22,8 +22,7 @@ describe('Client', () => {
controller.data = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'}; controller.data = {townFk: 1, provinceFk: 1, countryFk: 1, code: '46460'};
jest.spyOn(controller.vnApp, 'showMessage'); jest.spyOn(controller.vnApp, 'showMessage');
$httpBackend.when('PATCH', `postcodes`, params).respond(200, params); $httpBackend.expect('PATCH', `postcodes`, params).respond(200, params);
$httpBackend.expect('PATCH', `postcodes`, params).respond(params);
controller.onAccept(); controller.onAccept();
$httpBackend.flush(); $httpBackend.flush();

View File

@ -21,8 +21,7 @@ describe('Client', () => {
let res = {name: 'Superman', classifications: []}; let res = {name: 'Superman', classifications: []};
jest.spyOn(controller, 'sumRisk').mockReturnThis(); jest.spyOn(controller, 'sumRisk').mockReturnThis();
$httpBackend.when('GET', `Clients/101/summary`).respond(200, res); $httpBackend.expect('GET', `Clients/101/summary`).respond(200, res);
$httpBackend.expect('GET', `Clients/101/summary`);
controller.$onChanges(); controller.$onChanges();
$httpBackend.flush(); $httpBackend.flush();

View File

@ -57,8 +57,7 @@ describe('Component VnClientWebAccess', () => {
expect(controller.canEnableCheckBox).toBeTruthy(); expect(controller.canEnableCheckBox).toBeTruthy();
$httpBackend.when('GET', `Clients/${controller.client.id}/isValidClient`).respond(false); $httpBackend.expectGET(`Clients/${controller.client.id}/isValidClient`).respond(false);
$httpBackend.expectGET(`Clients/${controller.client.id}/isValidClient`);
controller.checkConditions(); controller.checkConditions();
$httpBackend.flush(); $httpBackend.flush();
@ -83,8 +82,7 @@ describe('Component VnClientWebAccess', () => {
controller.newPassword = 'm24x8'; controller.newPassword = 'm24x8';
controller.repeatPassword = 'm24x8'; controller.repeatPassword = 'm24x8';
controller.canChangePassword = true; controller.canChangePassword = true;
$httpBackend.when('PATCH', 'Accounts/1234').respond('done'); $httpBackend.expectPATCH('Accounts/1234', {password: 'm24x8'}).respond('done');
$httpBackend.expectPATCH('Accounts/1234', {password: 'm24x8'});
controller.onPassChange('accept'); controller.onPassChange('accept');
$httpBackend.flush(); $httpBackend.flush();
}); });

View File

@ -25,8 +25,7 @@ describe('Component vnClientWebPayment', () => {
let query = 'Clients/confirmTransaction'; let query = 'Clients/confirmTransaction';
controller.confirm(transaction); controller.confirm(transaction);
$httpBackend.when('POST', query, transaction).respond('ok'); $httpBackend.expect('POST', query, transaction).respond('ok');
$httpBackend.expect('POST', query, transaction);
$httpBackend.flush(); $httpBackend.flush();
}); });
}); });

View File

@ -19,7 +19,6 @@ describe('InvoiceOut', () => {
describe('getSummary()', () => { describe('getSummary()', () => {
it('should perform a query to set summary', () => { it('should perform a query to set summary', () => {
$httpBackend.when('GET', `InvoiceOuts/1/summary`).respond(200, 'the data you are looking for'); $httpBackend.when('GET', `InvoiceOuts/1/summary`).respond(200, 'the data you are looking for');
$httpBackend.expect('GET', `InvoiceOuts/1/summary`);
controller.getSummary(); controller.getSummary();
$httpBackend.flush(); $httpBackend.flush();

View File

@ -19,8 +19,7 @@ describe('Item', () => {
describe('getSummary()', () => { describe('getSummary()', () => {
it('should perform a query to set summary', () => { it('should perform a query to set summary', () => {
let data = {id: 1, name: 'Gem of mind'}; let data = {id: 1, name: 'Gem of mind'};
$httpBackend.when('GET', `Items/1/getSummary`).respond(200, data); $httpBackend.expect('GET', `Items/1/getSummary`).respond(200, data);
$httpBackend.expect('GET', `Items/1/getSummary`);
controller.getSummary(); controller.getSummary();
$httpBackend.flush(); $httpBackend.flush();

View File

@ -91,12 +91,11 @@ describe('Order', () => {
jest.spyOn(controller.vnApp, 'showSuccess'); jest.spyOn(controller.vnApp, 'showSuccess');
jest.spyOn(controller.$state, 'go'); jest.spyOn(controller.$state, 'go');
$httpBackend.when('POST', 'Orders/new', {landed: 101, addressId: 101, agencyModeId: 101}).respond(200, 1); $httpBackend.expect('POST', 'Orders/new', {landed: 101, addressId: 101, agencyModeId: 101}).respond(200, 1);
$httpBackend.expect('POST', 'Orders/new', {landed: 101, addressId: 101, agencyModeId: 101});
controller.createOrder(); controller.createOrder();
$httpBackend.flush(); $httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.$state.go).toHaveBeenCalledWith('order.card.catalog', {id: 1}); expect(controller.$state.go).toHaveBeenCalledWith('order.card.catalog', {id: 1});
}); });
}); });

View File

@ -17,7 +17,6 @@ describe('Route', () => {
describe('getSummary()', () => { describe('getSummary()', () => {
it('should perform a query to set summary', () => { it('should perform a query to set summary', () => {
$httpBackend.when('GET', `Routes/1/summary`).respond(200, 24); $httpBackend.when('GET', `Routes/1/summary`).respond(200, 24);
$httpBackend.expect('GET', `Routes/1/summary`);
controller.getSummary(); controller.getSummary();
$httpBackend.flush(); $httpBackend.flush();

View File

@ -101,7 +101,7 @@ describe('Route', () => {
controller.setPriority(ticketId, priority); controller.setPriority(ticketId, priority);
$httpBackend.flush(); $httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.$.model.refresh).toHaveBeenCalledWith(); expect(controller.$.model.refresh).toHaveBeenCalledWith();
}); });
}); });
@ -318,7 +318,7 @@ describe('Route', () => {
controller.insert(ticketId); controller.insert(ticketId);
$httpBackend.flush(); $httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.$.model.refresh).toHaveBeenCalledWith(); expect(controller.$.model.refresh).toHaveBeenCalledWith();
}); });
}); });

View File

@ -251,8 +251,7 @@ describe('Ticket', () => {
}; };
filter = encodeURIComponent(JSON.stringify(filter)); filter = encodeURIComponent(JSON.stringify(filter));
$httpBackend.when('GET', `Clients/${clientId}/addresses?filter=${filter}`).respond(200); $httpBackend.expect('GET', `Clients/${clientId}/addresses?filter=${filter}`).respond(200);
$httpBackend.expect('GET', `Clients/${clientId}/addresses?filter=${filter}`);
controller.clientAddressesList(clientId); controller.clientAddressesList(clientId);
$httpBackend.flush(); $httpBackend.flush();
}); });
@ -262,8 +261,7 @@ describe('Ticket', () => {
it('should return the default address from choosed client', async() => { it('should return the default address from choosed client', async() => {
const clientId = 102; const clientId = 102;
$httpBackend.when('GET', `Clients/${clientId}`).respond(200); $httpBackend.expect('GET', `Clients/${clientId}`).respond(200);
$httpBackend.expect('GET', `Clients/${clientId}`);
controller.getClientDefaultAddress(clientId); controller.getClientDefaultAddress(clientId);
$httpBackend.flush(); $httpBackend.flush();
}); });
@ -273,8 +271,7 @@ describe('Ticket', () => {
it('should return an available zone', async() => { it('should return an available zone', async() => {
const zoneId = 5; const zoneId = 5;
const agencyModeFk = 8; const agencyModeFk = 8;
$httpBackend.when('GET', `Zones/${zoneId}`).respond(200, {agencyModeFk}); $httpBackend.expect('GET', `Zones/${zoneId}`).respond(200, {agencyModeFk});
$httpBackend.expect('GET', `Zones/${zoneId}`);
controller.onChangeZone(zoneId); controller.onChangeZone(zoneId);
$httpBackend.flush(); $httpBackend.flush();
@ -337,8 +334,7 @@ describe('Ticket', () => {
}; };
const serializedParams = $httpParamSerializer(params); const serializedParams = $httpParamSerializer(params);
$httpBackend.when('GET', `Agencies/getLanded?${serializedParams}`).respond(200, expectedResult); $httpBackend.expect('GET', `Agencies/getLanded?${serializedParams}`).respond(200, expectedResult);
$httpBackend.expect('GET', `Agencies/getLanded?${serializedParams}`);
controller.getLanded(params); controller.getLanded(params);
$httpBackend.flush(); $httpBackend.flush();
@ -359,8 +355,7 @@ describe('Ticket', () => {
}; };
const serializedParams = $httpParamSerializer(params); const serializedParams = $httpParamSerializer(params);
$httpBackend.when('GET', `Agencies/getShipped?${serializedParams}`).respond(200, expectedResult); $httpBackend.expect('GET', `Agencies/getShipped?${serializedParams}`).respond(200, expectedResult);
$httpBackend.expect('GET', `Agencies/getShipped?${serializedParams}`);
controller.getShipped(params); controller.getShipped(params);
$httpBackend.flush(); $httpBackend.flush();

View File

@ -44,8 +44,7 @@ describe('Ticket', () => {
where: {code: 'ticket'} where: {code: 'ticket'}
}}; }};
let serializedParams = $httpParamSerializer(params); let serializedParams = $httpParamSerializer(params);
$httpBackend.when('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 14, code: 'ticket'}); $httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 14, code: 'ticket'});
$httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`);
controller.setDefaultParams(); controller.setDefaultParams();
$httpBackend.flush(); $httpBackend.flush();
@ -68,8 +67,7 @@ describe('Ticket', () => {
describe('getAllowedContentTypes()', () => { describe('getAllowedContentTypes()', () => {
it('should make an HTTP GET request to get the allowed content types', () => { it('should make an HTTP GET request to get the allowed content types', () => {
const expectedResponse = ['image/png', 'image/jpg']; const expectedResponse = ['image/png', 'image/jpg'];
$httpBackend.when('GET', `ticketDms/allowedContentTypes`).respond(expectedResponse); $httpBackend.expect('GET', `ticketDms/allowedContentTypes`).respond(expectedResponse);
$httpBackend.expect('GET', `ticketDms/allowedContentTypes`);
controller.getAllowedContentTypes(); controller.getAllowedContentTypes();
$httpBackend.flush(); $httpBackend.flush();

View File

@ -45,7 +45,6 @@ describe('Ticket', () => {
hasFileAttached: false hasFileAttached: false
}; };
$httpBackend.when('GET', `Dms/${dmsId}`).respond(expectedResponse);
$httpBackend.expect('GET', `Dms/${dmsId}`).respond(expectedResponse); $httpBackend.expect('GET', `Dms/${dmsId}`).respond(expectedResponse);
controller.setDefaultParams(); controller.setDefaultParams();
$httpBackend.flush(); $httpBackend.flush();
@ -70,8 +69,7 @@ describe('Ticket', () => {
describe('getAllowedContentTypes()', () => { describe('getAllowedContentTypes()', () => {
it('should make an HTTP GET request to get the allowed content types', () => { it('should make an HTTP GET request to get the allowed content types', () => {
const expectedResponse = ['image/png', 'image/jpg']; const expectedResponse = ['image/png', 'image/jpg'];
$httpBackend.when('GET', `ticketDms/allowedContentTypes`).respond(expectedResponse); $httpBackend.expect('GET', `ticketDms/allowedContentTypes`).respond(expectedResponse);
$httpBackend.expect('GET', `ticketDms/allowedContentTypes`);
controller.getAllowedContentTypes(); controller.getAllowedContentTypes();
$httpBackend.flush(); $httpBackend.flush();

View File

@ -248,7 +248,7 @@ describe('Ticket', () => {
$httpBackend.flush(); $httpBackend.flush();
expect(controller.card.reload).toHaveBeenCalledWith(); expect(controller.card.reload).toHaveBeenCalledWith();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.resetChanges).toHaveBeenCalledWith(); expect(controller.resetChanges).toHaveBeenCalledWith();
}); });
}); });
@ -267,7 +267,7 @@ describe('Ticket', () => {
$httpBackend.flush(); $httpBackend.flush();
expect(controller.removeSelectedSales).toHaveBeenCalledWith(); expect(controller.removeSelectedSales).toHaveBeenCalledWith();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.resetChanges).toHaveBeenCalledWith(); expect(controller.resetChanges).toHaveBeenCalledWith();
}); });
}); });
@ -371,7 +371,7 @@ describe('Ticket', () => {
expect(selectedSale.price).toEqual(2); expect(selectedSale.price).toEqual(2);
expect(controller.refreshTotal).toHaveBeenCalledWith(); expect(controller.refreshTotal).toHaveBeenCalledWith();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.$.editPricePopover.hide).toHaveBeenCalledWith(); expect(controller.$.editPricePopover.hide).toHaveBeenCalledWith();
expect(controller.resetChanges).toHaveBeenCalledWith(); expect(controller.resetChanges).toHaveBeenCalledWith();
}); });
@ -472,7 +472,7 @@ describe('Ticket', () => {
expect(firstSelectedSale.discount).toEqual(expectedDiscount); expect(firstSelectedSale.discount).toEqual(expectedDiscount);
expect(secondSelectedSale.discount).toEqual(expectedDiscount); expect(secondSelectedSale.discount).toEqual(expectedDiscount);
expect(controller.refreshTotal).toHaveBeenCalledWith(); expect(controller.refreshTotal).toHaveBeenCalledWith();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.resetChanges).toHaveBeenCalledWith(); expect(controller.resetChanges).toHaveBeenCalledWith();
}); });
}); });
@ -678,7 +678,7 @@ describe('Ticket', () => {
controller.addSale(newSale); controller.addSale(newSale);
$httpBackend.flush(); $httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.refreshTotal).toHaveBeenCalledWith(); expect(controller.refreshTotal).toHaveBeenCalledWith();
expect(controller.resetChanges).toHaveBeenCalledWith(); expect(controller.resetChanges).toHaveBeenCalledWith();
}); });
@ -719,7 +719,7 @@ describe('Ticket', () => {
controller.calculateSalePrice(); controller.calculateSalePrice();
$httpBackend.flush(); $httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.$.model.refresh).toHaveBeenCalledWith(); expect(controller.$.model.refresh).toHaveBeenCalledWith();
expect(controller.refreshTotal).toHaveBeenCalledWith(); expect(controller.refreshTotal).toHaveBeenCalledWith();
}); });

View File

@ -18,7 +18,6 @@ describe('Ticket', () => {
it('should perform a GET query and define the summary property', () => { it('should perform a GET query and define the summary property', () => {
let res = {id: 1, nickname: 'Batman'}; let res = {id: 1, nickname: 'Batman'};
$httpBackend.when('GET', `Tickets/1/summary`).respond(200, res); $httpBackend.when('GET', `Tickets/1/summary`).respond(200, res);
$httpBackend.expect('GET', `Tickets/1/summary`);
controller.ticket = {id: 1}; controller.ticket = {id: 1};
$httpBackend.flush(); $httpBackend.flush();

View File

@ -23,7 +23,7 @@ describe('ticket weekly', () => {
controller.onUpdate('ticketFk', 'field', 'value'); controller.onUpdate('ticketFk', 'field', 'value');
$httpBackend.flush(); $httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
}); });
}); });
@ -38,7 +38,7 @@ describe('ticket weekly', () => {
controller.onDeleteWeeklyAccept('ticketFk'); controller.onDeleteWeeklyAccept('ticketFk');
$httpBackend.flush(); $httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.$.model.remove).toHaveBeenCalledWith(0); expect(controller.$.model.remove).toHaveBeenCalledWith(0);
}); });
}); });

View File

@ -40,8 +40,7 @@ describe('Ticket', () => {
where: {code: 'miscellaneous'} where: {code: 'miscellaneous'}
}}; }};
let serializedParams = $httpParamSerializer(params); let serializedParams = $httpParamSerializer(params);
$httpBackend.when('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: dmsTypeId, code: 'miscellaneous'}); $httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: dmsTypeId, code: 'miscellaneous'});
$httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`);
controller.setDefaultParams(); controller.setDefaultParams();
$httpBackend.flush(); $httpBackend.flush();
@ -54,8 +53,7 @@ describe('Ticket', () => {
describe('getAllowedContentTypes()', () => { describe('getAllowedContentTypes()', () => {
it('should make an HTTP GET request to get the allowed content types', () => { it('should make an HTTP GET request to get the allowed content types', () => {
const expectedResponse = ['application/pdf', 'image/png', 'image/jpg']; const expectedResponse = ['application/pdf', 'image/png', 'image/jpg'];
$httpBackend.when('GET', `TravelThermographs/allowedContentTypes`).respond(expectedResponse); $httpBackend.expect('GET', `TravelThermographs/allowedContentTypes`).respond(expectedResponse);
$httpBackend.expect('GET', `TravelThermographs/allowedContentTypes`);
controller.getAllowedContentTypes(); controller.getAllowedContentTypes();
$httpBackend.flush(); $httpBackend.flush();

View File

@ -79,8 +79,7 @@ describe('Worker', () => {
describe('getAllowedContentTypes()', () => { describe('getAllowedContentTypes()', () => {
it('should make an HTTP GET request to get the allowed content types', () => { it('should make an HTTP GET request to get the allowed content types', () => {
const expectedResponse = ['image/png', 'image/jpg']; const expectedResponse = ['image/png', 'image/jpg'];
$httpBackend.when('GET', `TravelThermographs/allowedContentTypes`).respond(expectedResponse); $httpBackend.expect('GET', `TravelThermographs/allowedContentTypes`).respond(expectedResponse);
$httpBackend.expect('GET', `TravelThermographs/allowedContentTypes`);
controller.getAllowedContentTypes(); controller.getAllowedContentTypes();
$httpBackend.flush(); $httpBackend.flush();

View File

@ -64,8 +64,7 @@ describe('Client', () => {
describe('getAllowedContentTypes()', () => { describe('getAllowedContentTypes()', () => {
it('should make an HTTP GET request to get the allowed content types', () => { it('should make an HTTP GET request to get the allowed content types', () => {
const expectedResponse = ['image/png', 'image/jpg']; const expectedResponse = ['image/png', 'image/jpg'];
$httpBackend.when('GET', `workerDms/allowedContentTypes`).respond(expectedResponse); $httpBackend.expect('GET', `workerDms/allowedContentTypes`).respond(expectedResponse);
$httpBackend.expect('GET', `workerDms/allowedContentTypes`);
controller.getAllowedContentTypes(); controller.getAllowedContentTypes();
$httpBackend.flush(); $httpBackend.flush();

View File

@ -46,7 +46,6 @@ describe('Worker', () => {
hasFileAttached: false hasFileAttached: false
}; };
$httpBackend.when('GET', `Dms/${dmsId}`).respond(expectedResponse);
$httpBackend.expect('GET', `Dms/${dmsId}`).respond(expectedResponse); $httpBackend.expect('GET', `Dms/${dmsId}`).respond(expectedResponse);
controller.setDefaultParams(); controller.setDefaultParams();
$httpBackend.flush(); $httpBackend.flush();
@ -71,8 +70,7 @@ describe('Worker', () => {
describe('getAllowedContentTypes()', () => { describe('getAllowedContentTypes()', () => {
it('should make an HTTP GET request to get the allowed content types', () => { it('should make an HTTP GET request to get the allowed content types', () => {
const expectedResponse = ['image/png', 'image/jpg']; const expectedResponse = ['image/png', 'image/jpg'];
$httpBackend.when('GET', `WorkerDms/allowedContentTypes`).respond(expectedResponse); $httpBackend.expect('GET', `WorkerDms/allowedContentTypes`).respond(expectedResponse);
$httpBackend.expect('GET', `WorkerDms/allowedContentTypes`);
controller.getAllowedContentTypes(); controller.getAllowedContentTypes();
$httpBackend.flush(); $httpBackend.flush();