salix/modules/ticket/front/summary/index.spec.js

47 lines
1.7 KiB
JavaScript

import './index';
describe('Ticket', () => {
describe('Component vnTicketSummary', () => {
let controller;
let $httpBackend;
beforeEach(ngModule('ticket'));
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
const $element = angular.element('<vn-ticket-summary></vn-ticket-summary>');
controller = $componentController('vnTicketSummary', {$element});
controller.ticket = {id: 1};
}));
describe('ticket()', () => {
it('should perform a GET query and define the summary property', () => {
let res = {id: 1, nickname: 'Batman'};
$httpBackend.when('GET', `Tickets/1/summary`).respond(200, res);
$httpBackend.expect('GET', `Tickets/1/summary`);
controller.ticket = {id: 1};
$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)');
});
});
});
});