updated e2e and unit tests

This commit is contained in:
Joan Sanchez 2019-09-24 14:03:30 +02:00
parent 92463b0ccd
commit d0fc74cefd
2 changed files with 22 additions and 10 deletions

View File

@ -92,13 +92,4 @@ describe('Ticket List sale path', () => {
expect(sales).toEqual(1); expect(sales).toEqual(1);
}); });
it('should navigate to the catalog by pressing the new item button', async() => {
const url = await nightmare
.waitToClick(selectors.ticketSales.newItemFromCatalogButton)
.waitForURL('/catalog')
.parsedUrl();
expect(url.hash).toContain('/catalog');
});
}); });

View File

@ -1,7 +1,7 @@
import '../index.js'; import '../index.js';
import watcher from 'core/mocks/watcher'; import watcher from 'core/mocks/watcher';
describe('Ticket', () => { fdescribe('Ticket', () => {
describe('Component vnTicketSale', () => { describe('Component vnTicketSale', () => {
let controller; let controller;
let $scope; let $scope;
@ -317,5 +317,26 @@ describe('Ticket', () => {
expect(lastActiveTickets[0].id).toEqual(4); expect(lastActiveTickets[0].id).toEqual(4);
}); });
}); });
describe('newOrderFromTicket()', () => {
it('should make an HTTP post query and then open the new order on a new tab', () => {
const params = {ticketFk: 1};
const expectedResponse = {id: 123};
window.open = jasmine.createSpy('open');
controller.$state.href = jasmine.createSpy('href')
.and.returnValue('/somePath');
$httpBackend.when('POST', `/api/Orders/newFromTicket`, params).respond(expectedResponse);
$httpBackend.expect('POST', `/api/Orders/newFromTicket`, params).respond(expectedResponse);
$httpBackend.whenGET(`/api/Tickets/1/subtotal`).respond(200, 227.5);
$httpBackend.whenGET(`/api/Tickets/1/getVAT`).respond(200, 10.5);
$httpBackend.whenGET(`/api/Tickets/1/isEditable`).respond();
controller.newOrderFromTicket();
$httpBackend.flush();
expect(window.open).toHaveBeenCalledWith('/somePath', '_blank');
});
});
}); });
}); });