2020-02-24 11:20:53 +00:00
|
|
|
import './index.js';
|
|
|
|
|
|
|
|
describe('Entry Component vnEntryDescriptor', () => {
|
2020-08-27 13:14:30 +00:00
|
|
|
let $httpBackend;
|
2020-02-24 11:20:53 +00:00
|
|
|
let controller;
|
2020-04-30 10:48:52 +00:00
|
|
|
const entry = {id: 2};
|
2020-02-24 11:20:53 +00:00
|
|
|
|
|
|
|
beforeEach(ngModule('entry'));
|
|
|
|
|
2020-08-27 13:14:30 +00:00
|
|
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
|
|
|
$httpBackend = _$httpBackend_;
|
2020-04-30 10:48:52 +00:00
|
|
|
controller = $componentController('vnEntryDescriptor', {$element: null}, {entry});
|
2020-02-24 11:20:53 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
describe('showEntryReport()', () => {
|
|
|
|
it('should open a new window showing a delivery note PDF document', () => {
|
2020-06-12 12:28:29 +00:00
|
|
|
jest.spyOn(controller.vnReport, 'show');
|
2020-04-30 10:48:52 +00:00
|
|
|
|
2020-06-12 12:28:29 +00:00
|
|
|
window.open = jasmine.createSpy('open');
|
2020-02-24 11:20:53 +00:00
|
|
|
const params = {
|
|
|
|
clientId: controller.vnConfig.storage.currentUserWorkerId,
|
2020-04-30 10:48:52 +00:00
|
|
|
entryId: entry.id
|
2020-02-24 11:20:53 +00:00
|
|
|
};
|
|
|
|
controller.showEntryReport();
|
|
|
|
|
2020-06-12 12:28:29 +00:00
|
|
|
expect(controller.vnReport.show).toHaveBeenCalledWith('entry-order', params);
|
2020-02-24 11:20:53 +00:00
|
|
|
});
|
|
|
|
});
|
2020-08-27 13:14:30 +00:00
|
|
|
|
|
|
|
describe('loadData()', () => {
|
|
|
|
it('should perform ask for the entry', () => {
|
|
|
|
let query = `Entries/${entry.id}`;
|
|
|
|
jest.spyOn(controller, 'getData');
|
|
|
|
|
|
|
|
$httpBackend.expectGET(query).respond();
|
|
|
|
controller.loadData();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.getData).toHaveBeenCalledTimes(1);
|
|
|
|
expect(controller.getData).toHaveBeenCalledWith(query, jasmine.any(Object));
|
|
|
|
});
|
|
|
|
});
|
2020-02-24 11:20:53 +00:00
|
|
|
});
|