53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
import './index.js';
|
|
import crudModel from 'core/mocks/crud-model';
|
|
|
|
describe('Component vnTicketAdvance', () => {
|
|
let controller;
|
|
let $httpBackend;
|
|
|
|
beforeEach(ngModule('ticket')
|
|
);
|
|
|
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
|
$httpBackend = _$httpBackend_;
|
|
const $element = angular.element('<vn-ticket-advance></vn-ticket-advance>');
|
|
controller = $componentController('vnTicketAdvance', {$element});
|
|
controller.$.model = crudModel;
|
|
controller.$.model.data = [{
|
|
id: 1,
|
|
checked: true,
|
|
state: 'OK'
|
|
}, {
|
|
id: 2,
|
|
checked: true,
|
|
state: 'Libre'
|
|
}];
|
|
}));
|
|
|
|
describe('checked()', () => {
|
|
it('should return an array of checked tickets', () => {
|
|
const result = controller.checked;
|
|
const firstRow = result[0];
|
|
const secondRow = result[1];
|
|
|
|
expect(result.length).toEqual(2);
|
|
expect(firstRow.id).toEqual(1);
|
|
expect(secondRow.id).toEqual(2);
|
|
});
|
|
});
|
|
|
|
describe('moveTicketsAdvance()', () => {
|
|
it('should make an HTTP Post query', () => {
|
|
jest.spyOn(controller.$.model, 'refresh');
|
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
$httpBackend.expectPOST(`Tickets/merge`).respond();
|
|
controller.moveTicketsAdvance();
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
|
expect(controller.$.model.refresh).toHaveBeenCalledWith();
|
|
});
|
|
});
|
|
});
|