65 lines
2.4 KiB
JavaScript
65 lines
2.4 KiB
JavaScript
|
import './index';
|
||
|
|
||
|
describe('Ticket', () => {
|
||
|
describe('Component vnTicketCard', () => {
|
||
|
let $componentController;
|
||
|
let controller;
|
||
|
let $state;
|
||
|
let $httpBackend;
|
||
|
|
||
|
beforeEach(() => {
|
||
|
angular.mock.module('ticket');
|
||
|
});
|
||
|
|
||
|
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => {
|
||
|
$componentController = _$componentController_;
|
||
|
$state = _$state_;
|
||
|
$state.params.id = 1;
|
||
|
$httpBackend = _$httpBackend_;
|
||
|
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
|
||
|
controller = $componentController('vnTicketCard', {$state: $state});
|
||
|
}));
|
||
|
|
||
|
describe('getTicket()', () => {
|
||
|
it('should perform a GET query and define the ticket property on controller', () => {
|
||
|
let filter = {
|
||
|
include: [
|
||
|
{relation: 'warehouse', scope: {fields: ['name']}},
|
||
|
{relation: 'agencyMode', scope: {fields: ['name']}},
|
||
|
{
|
||
|
relation: 'client',
|
||
|
scope: {
|
||
|
fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'],
|
||
|
include: {
|
||
|
relation: 'salesPerson',
|
||
|
fields: ['firstName', 'name']
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
relation: 'tracking',
|
||
|
scope: {
|
||
|
fields: ['stateFk'],
|
||
|
include: {
|
||
|
relation: 'state',
|
||
|
fields: ['name']
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
};
|
||
|
|
||
|
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.getTicket();
|
||
|
$httpBackend.flush();
|
||
|
|
||
|
expect(controller.ticket).toBeDefined();
|
||
|
expect(controller.ticket.id).toEqual(1);
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
});
|