feat: add frontTest
gitea/salix/pipeline/head This commit is unstable
Details
gitea/salix/pipeline/head This commit is unstable
Details
This commit is contained in:
parent
8dcd430178
commit
3da9a775bd
|
@ -123,35 +123,41 @@ describe('component vnZoneEvents', () => {
|
|||
|
||||
expect(controller.createExclusion).toHaveBeenCalledWith(days);
|
||||
});
|
||||
});
|
||||
|
||||
// it('should call the exclusionDelete() method', () => {
|
||||
// jest.spyOn(controller, 'exclusionDelete').mockReturnThis();
|
||||
describe('editExclusion()', () => {
|
||||
it('shoud set the excludeSelected.type = "specificLocations" and then call the excludeDialog show() method', () => {
|
||||
controller.$.excludeDialog = {show: jest.fn()};
|
||||
|
||||
// const weekday = {};
|
||||
// const days = [];
|
||||
// const type = 'EventType';
|
||||
// const events = [];
|
||||
// const exclusions = [{id: 1}];
|
||||
// const geoExclusions = [];
|
||||
// controller.editMode = 'delete';
|
||||
// controller.onSelection(days, type, weekday, events, exclusions, geoExclusions);
|
||||
controller.exclusionsGeo = [{id: 1}];
|
||||
controller.editExclusion();
|
||||
|
||||
// expect(controller.exclusionDelete).toHaveBeenCalledWith(exclusions);
|
||||
// });
|
||||
expect(controller.excludeSelected.type).toEqual('specificLocations');
|
||||
expect(controller.$.excludeDialog.show).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
// it('should call the exclusionCreate() method', () => {
|
||||
// jest.spyOn(controller, 'exclusionCreate').mockReturnThis();
|
||||
it('shoud set the excludeSelected.type = "all" and then call the excludeDialog show() method', () => {
|
||||
controller.$.excludeDialog = {show: jest.fn()};
|
||||
|
||||
// const weekday = {};
|
||||
// const days = [{dated: new Date()}];
|
||||
// const type = 'EventType';
|
||||
// const events = [];
|
||||
// const exclusions = [];
|
||||
// controller.editMode = 'delete';
|
||||
// controller.onSelection(days, type, weekday, events, exclusions);
|
||||
controller.exclusions = [{id: 1}];
|
||||
controller.editExclusion();
|
||||
|
||||
// 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()', () => {
|
||||
|
@ -311,4 +317,30 @@ describe('component vnZoneEvents', () => {
|
|||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue