48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
|
import './index.js';
|
||
|
|
||
|
describe('Travel Component vnTravelExtraCommunity', () => {
|
||
|
let controller;
|
||
|
let $httpBackend;
|
||
|
let travel = {
|
||
|
id: 1,
|
||
|
warehouseInFk: 1,
|
||
|
totalEntries: 3,
|
||
|
isDelivered: false
|
||
|
};
|
||
|
|
||
|
beforeEach(ngModule('travel'));
|
||
|
|
||
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
||
|
$httpBackend = _$httpBackend_;
|
||
|
const $element = angular.element('<vn-travel-extra-community></vn-travel-extra-community>');
|
||
|
controller = $componentController('vnTravelExtraCommunity', {$element});
|
||
|
controller.$.summary = {show: jasmine.createSpy('show')};
|
||
|
}));
|
||
|
|
||
|
describe('changeReference()', () => {
|
||
|
it('should make an HTTP query', () => {
|
||
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||
|
|
||
|
const travel = {id: 1, ref: 'New reference'};
|
||
|
const expectedData = {ref: 'New reference'};
|
||
|
$httpBackend.expect('PATCH', `Travels/${travel.id}`, expectedData).respond(200);
|
||
|
controller.changeReference(travel);
|
||
|
$httpBackend.flush();
|
||
|
|
||
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
||
|
});
|
||
|
});
|
||
|
|
||
|
xdescribe('changeReference()', () => {
|
||
|
it('should make an HTTP query', () => {
|
||
|
let event = new MouseEvent('click', {
|
||
|
bubbles: true,
|
||
|
cancelable: true
|
||
|
});
|
||
|
controller.preview(event, travel);
|
||
|
|
||
|
expect(controller.$.summary.show).toHaveBeenCalledWith();
|
||
|
});
|
||
|
});
|
||
|
});
|