1781-zoneHoliday #994

Merged
joan merged 49 commits from 1781-zoneHoliday into dev 2022-08-03 06:41:31 +00:00
1 changed files with 55 additions and 23 deletions
Showing only changes of commit 3da9a775bd - Show all commits

View File

@ -123,35 +123,41 @@ describe('component vnZoneEvents', () => {
expect(controller.createExclusion).toHaveBeenCalledWith(days); expect(controller.createExclusion).toHaveBeenCalledWith(days);
}); });
});
// it('should call the exclusionDelete() method', () => { describe('editExclusion()', () => {
// jest.spyOn(controller, 'exclusionDelete').mockReturnThis(); it('shoud set the excludeSelected.type = "specificLocations" and then call the excludeDialog show() method', () => {
controller.$.excludeDialog = {show: jest.fn()};
// const weekday = {}; controller.exclusionsGeo = [{id: 1}];
// const days = []; controller.editExclusion();
// const type = 'EventType';
// const events = [];
// const exclusions = [{id: 1}];
// const geoExclusions = [];
// controller.editMode = 'delete';
// controller.onSelection(days, type, weekday, events, exclusions, geoExclusions);
// expect(controller.exclusionDelete).toHaveBeenCalledWith(exclusions); expect(controller.excludeSelected.type).toEqual('specificLocations');
// }); expect(controller.$.excludeDialog.show).toHaveBeenCalledWith();
});
// it('should call the exclusionCreate() method', () => { it('shoud set the excludeSelected.type = "all" and then call the excludeDialog show() method', () => {
// jest.spyOn(controller, 'exclusionCreate').mockReturnThis(); controller.$.excludeDialog = {show: jest.fn()};
// const weekday = {}; controller.exclusions = [{id: 1}];
// const days = [{dated: new Date()}]; controller.editExclusion();
// const type = 'EventType';
// const events = [];
// const exclusions = [];
// controller.editMode = 'delete';
// controller.onSelection(days, type, weekday, events, exclusions);
// expect(controller.exclusionCreate).toHaveBeenCalledWith(days); expect(controller.excludeSelected.type).toEqual('all');
// }); expect(controller.$.excludeDialog.show).toHaveBeenCalledWith();
});
});
describe('createExclusion()', () => {
it('shoud set the excludeSelected property and then call the excludeDialog show() method', () => {
controller.$.excludeDialog = {show: jest.fn()};
const days = [new Date()];
controller.createExclusion(days);
expect(controller.excludeSelected).toBeDefined();
expect(controller.isNew).toBeTruthy();
expect(controller.$.excludeDialog.show).toHaveBeenCalledWith();
});
}); });
describe('createInclusion()', () => { describe('createInclusion()', () => {
@ -311,4 +317,30 @@ describe('component vnZoneEvents', () => {
expect(controller.refresh).toHaveBeenCalledWith(); expect(controller.refresh).toHaveBeenCalledWith();
}); });
}); });
describe('exclusionGeoDelete()', () => {
it('shoud make an HTTP DELETE query twice and then call the refresh() method', () => {
jest.spyOn(controller, 'refresh').mockReturnThis();
const exclusionsGeo = [{id: 1}];
const firstExclusionGeoId = 1;
$httpBackend.when('DELETE', `Zones/1/exclusions/${firstExclusionGeoId}`).respond(200);
controller.exclusionDelete(exclusionsGeo);
$httpBackend.flush();
expect(controller.refresh).toHaveBeenCalledWith();
});
it('shoud make an HTTP DELETE query for every exclusion and then call the refresh() method', () => {
jest.spyOn(controller, 'refresh').mockReturnThis();
jest.spyOn(controller.$http, 'delete').mockReturnValue(200);
const exclusionsGeo = [{id: 1}, {id: 2}, {id: 3}, {id: 4}];
controller.exclusionDelete(exclusionsGeo);
$scope.$apply();
expect(controller.$http.delete).toHaveBeenCalledTimes(4);
expect(controller.refresh).toHaveBeenCalledWith();
});
});
}); });