ticket summary unit test
This commit is contained in:
parent
f0df298138
commit
3c79f3cc7b
|
@ -8,8 +8,7 @@ class Controller {
|
|||
}
|
||||
|
||||
$onChanges() {
|
||||
if (!this.ticket)
|
||||
return;
|
||||
if (!this.ticket) return;
|
||||
|
||||
this.$http.get(`/ticket/api/Tickets/${this.ticket.id}/summary`).then(res => {
|
||||
if (res && res.data)
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
import './index';
|
||||
|
||||
fdescribe('Ticket', () => {
|
||||
describe('Component vnTicketSummary', () => {
|
||||
let $componentController;
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
|
||||
beforeEach(() => {
|
||||
angular.mock.module('ticket');
|
||||
});
|
||||
|
||||
beforeEach(angular.mock.inject((_$componentController_, _$httpBackend_) => {
|
||||
$componentController = _$componentController_;
|
||||
$httpBackend = _$httpBackend_;
|
||||
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
|
||||
controller = $componentController('vnTicketSummary');
|
||||
controller.ticket = {id: 1};
|
||||
}));
|
||||
|
||||
describe('$onChanges()', () => {
|
||||
it('should perform a GET query and define summary property', () => {
|
||||
let res = {id: 1, nickname: 'Batman'};
|
||||
$httpBackend.when('GET', `/ticket/api/Tickets/1/summary`).respond(200, res);
|
||||
$httpBackend.expect('GET', `/ticket/api/Tickets/1/summary`);
|
||||
controller.$onChanges();
|
||||
$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)');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue