Updated unit tests
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2021-06-18 08:03:55 +02:00
parent bb80621890
commit bc7c288742
2 changed files with 23 additions and 2 deletions

View File

@ -18,9 +18,14 @@ describe('Component vnChip', () => {
it(`should emit remove event`, () => {
controller.emit = () => {};
jest.spyOn(controller, 'emit');
controller.onRemove();
expect(controller.emit).toHaveBeenCalledWith('remove');
const $event = new Event('click');
const target = document.createElement('div');
target.dispatchEvent($event);
controller.onRemove($event);
expect(controller.emit).toHaveBeenCalledWith('remove', {$event});
});
});
});

View File

@ -113,5 +113,21 @@ describe('Component vnWorkerTimeControl', () => {
expect(result).toEqual('01:00');
});
});
describe('save() ', () => {
it(`should make a query an then call to the fetchHours() method`, () => {
controller.fetchHours = jest.fn();
controller.selectedRow = {id: 1, timed: new Date(), direction: 'in'};
controller.$.editEntry = {
hide: () => {}
};
const expectedParams = {direction: 'in'};
$httpBackend.expect('POST', 'WorkerTimeControls/1/updateTimeEntry', expectedParams).respond(200);
controller.save();
$httpBackend.flush();
expect(controller.fetchHours).toHaveBeenCalledWith();
});
});
});
});