35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
import './index';
|
|
|
|
describe('Ticket', () => {
|
|
describe('Component vnTicketCard', () => {
|
|
let controller;
|
|
let $state;
|
|
let $httpBackend;
|
|
|
|
beforeEach(ngModule('ticket'));
|
|
|
|
beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_) => {
|
|
$state = _$state_;
|
|
$state.params.id = 1;
|
|
$httpBackend = _$httpBackend_;
|
|
controller = $componentController('vnTicketCard', {$state});
|
|
}));
|
|
|
|
describe('getCard()', () => {
|
|
it('should perform a GET query and define the ticket property on controller', () => {
|
|
let filter = controller.filter;
|
|
|
|
filter = encodeURIComponent(JSON.stringify(filter));
|
|
|
|
$httpBackend.when('GET', `/ticket/api/Tickets/1?filter=${filter}`).respond({id: 1});
|
|
$httpBackend.expect('GET', `/ticket/api/Tickets/1?filter=${filter}`);
|
|
controller.getCard();
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.ticket).toBeDefined();
|
|
expect(controller.ticket.id).toEqual(1);
|
|
});
|
|
});
|
|
});
|
|
});
|