2018-08-10 05:43:39 +00:00
|
|
|
import './index';
|
|
|
|
|
2018-08-10 09:40:48 +00:00
|
|
|
describe('Ticket', () => {
|
2018-08-10 05:43:39 +00:00
|
|
|
describe('Component vnTicketSummary', () => {
|
|
|
|
let controller;
|
|
|
|
let $httpBackend;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('ticket'));
|
2018-08-10 05:43:39 +00:00
|
|
|
|
2020-07-23 14:46:16 +00:00
|
|
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
2018-08-10 05:43:39 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
2020-03-18 07:35:59 +00:00
|
|
|
const $element = angular.element('<vn-ticket-summary></vn-ticket-summary>');
|
|
|
|
controller = $componentController('vnTicketSummary', {$element});
|
2018-08-10 05:43:39 +00:00
|
|
|
controller.ticket = {id: 1};
|
|
|
|
}));
|
|
|
|
|
2018-09-04 09:49:00 +00:00
|
|
|
describe('ticket()', () => {
|
2020-02-26 12:22:52 +00:00
|
|
|
it('should perform a GET query and define the summary property', () => {
|
2018-08-10 05:43:39 +00:00
|
|
|
let res = {id: 1, nickname: 'Batman'};
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.when('GET', `Tickets/1/summary`).respond(200, res);
|
2018-09-04 09:49:00 +00:00
|
|
|
controller.ticket = {id: 1};
|
2018-08-10 05:43:39 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.summary).toBeDefined();
|
|
|
|
expect(controller.summary.nickname).toEqual('Batman');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('formattedAddress()', () => {
|
2021-06-13 17:16:35 +00:00
|
|
|
it('should return the full fromatted address with city and province', () => {
|
2018-08-10 05:43:39 +00:00
|
|
|
controller.summary = {
|
|
|
|
address: {
|
|
|
|
province: {
|
|
|
|
name: 'Gotham'
|
|
|
|
},
|
|
|
|
street: '1007 Mountain Drive',
|
2021-06-13 17:16:35 +00:00
|
|
|
postalCode: 46060,
|
2018-08-10 05:43:39 +00:00
|
|
|
city: 'Gotham'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-06-13 17:16:35 +00:00
|
|
|
expect(controller.formattedAddress).toEqual('1007 Mountain Drive - 46060 - Gotham (Gotham)');
|
2018-08-10 05:43:39 +00:00
|
|
|
});
|
|
|
|
});
|
2021-12-30 09:45:19 +00:00
|
|
|
|
2023-09-13 17:48:58 +00:00
|
|
|
describe('state()', () => {
|
2021-12-30 09:45:19 +00:00
|
|
|
it('should change the state', () => {
|
|
|
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
const value = 'myTicketState';
|
|
|
|
|
|
|
|
let res = {id: 1, nickname: 'myNickname'};
|
|
|
|
$httpBackend.when('GET', `Tickets/1/summary`).respond(200, res);
|
2023-10-27 16:03:40 +00:00
|
|
|
$httpBackend.expectPOST(`Tickets/state`).respond(200, 'ok');
|
2023-09-13 17:48:58 +00:00
|
|
|
controller.state(value);
|
2021-12-30 09:45:19 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
|
|
|
});
|
|
|
|
});
|
2018-08-10 05:43:39 +00:00
|
|
|
});
|
|
|
|
});
|