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
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
|
2018-08-10 05:43:39 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
controller = $componentController('vnTicketSummary');
|
|
|
|
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);
|
|
|
|
$httpBackend.expect('GET', `Tickets/1/summary`);
|
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()', () => {
|
|
|
|
it('should return a full fromatted address with city and province', () => {
|
|
|
|
controller.summary = {
|
|
|
|
address: {
|
|
|
|
province: {
|
|
|
|
name: 'Gotham'
|
|
|
|
},
|
|
|
|
street: '1007 Mountain Drive',
|
|
|
|
city: 'Gotham'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(controller.formattedAddress).toEqual('1007 Mountain Drive - Gotham (Gotham)');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|