fix: events 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
f7be419bbe
commit
8dcd430178
|
@ -49,32 +49,79 @@ describe('component vnZoneEvents', () => {
|
|||
});
|
||||
|
||||
describe('onSelection()', () => {
|
||||
it('should call the edit() method', () => {
|
||||
jest.spyOn(controller, 'edit').mockReturnThis();
|
||||
it('should call the editInclusion() method', () => {
|
||||
jest.spyOn(controller, 'editInclusion').mockReturnThis();
|
||||
|
||||
const weekday = {};
|
||||
const days = [];
|
||||
const type = 'EventType';
|
||||
const events = [{name: 'Event'}];
|
||||
const exclusions = [];
|
||||
const exclusionsGeo = [];
|
||||
controller.editMode = 'include';
|
||||
controller.onSelection(days, type, weekday, events, exclusions);
|
||||
controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo);
|
||||
|
||||
expect(controller.edit).toHaveBeenCalledWith({name: 'Event'});
|
||||
expect(controller.editInclusion).toHaveBeenCalledWith({name: 'Event'});
|
||||
});
|
||||
|
||||
it('should call the create() method', () => {
|
||||
jest.spyOn(controller, 'create').mockReturnThis();
|
||||
it('should call the createInclusion() method', () => {
|
||||
jest.spyOn(controller, 'createInclusion').mockReturnThis();
|
||||
|
||||
const weekday = {dated: new Date()};
|
||||
const days = [weekday];
|
||||
const type = 'EventType';
|
||||
const events = [];
|
||||
const exclusions = [];
|
||||
const exclusionsGeo = [];
|
||||
controller.editMode = 'include';
|
||||
controller.onSelection(days, type, weekday, events, exclusions);
|
||||
controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo);
|
||||
|
||||
expect(controller.create).toHaveBeenCalledWith(type, days, weekday);
|
||||
expect(controller.createInclusion).toHaveBeenCalledWith(type, days, weekday);
|
||||
});
|
||||
|
||||
it('should call the editExclusion() method with exclusions', () => {
|
||||
jest.spyOn(controller, 'editExclusion').mockReturnThis();
|
||||
|
||||
const weekday = {};
|
||||
const days = [];
|
||||
const type = 'EventType';
|
||||
const events = [];
|
||||
const exclusions = [{name: 'Exclusion'}];
|
||||
const exclusionsGeo = [];
|
||||
controller.editMode = 'exclude';
|
||||
controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo);
|
||||
|
||||
expect(controller.editExclusion).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('should call the editExclusion() method with exclusionsGeo', () => {
|
||||
jest.spyOn(controller, 'editExclusion').mockReturnThis();
|
||||
|
||||
const weekday = {};
|
||||
const days = [];
|
||||
const type = 'EventType';
|
||||
const events = [];
|
||||
const exclusions = [];
|
||||
const exclusionsGeo = [{name: 'GeoExclusion'}];
|
||||
controller.editMode = 'exclude';
|
||||
controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo);
|
||||
|
||||
expect(controller.editExclusion).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('should call the createExclusion() method', () => {
|
||||
jest.spyOn(controller, 'createExclusion').mockReturnThis();
|
||||
|
||||
const weekday = {};
|
||||
const days = [{dated: new Date()}];
|
||||
const type = 'EventType';
|
||||
const events = [];
|
||||
const exclusions = [];
|
||||
const exclusionsGeo = [];
|
||||
controller.editMode = 'exclude';
|
||||
controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo);
|
||||
|
||||
expect(controller.createExclusion).toHaveBeenCalledWith(days);
|
||||
});
|
||||
|
||||
// it('should call the exclusionDelete() method', () => {
|
||||
|
@ -92,17 +139,6 @@ describe('component vnZoneEvents', () => {
|
|||
// expect(controller.exclusionDelete).toHaveBeenCalledWith(exclusions);
|
||||
// });
|
||||
|
||||
it('should call the exclusionCreate() method', () => {
|
||||
jest.spyOn(controller, 'exclusionCreate').mockReturnThis();
|
||||
|
||||
const days = [{dated: new Date()}];
|
||||
controller.days = days;
|
||||
controller.excludeSelected = {type: 'all'};
|
||||
controller.onExcludeResponse('accept');
|
||||
|
||||
expect(controller.exclusionCreate).toHaveBeenCalledWith(days);
|
||||
});
|
||||
|
||||
// it('should call the exclusionCreate() method', () => {
|
||||
// jest.spyOn(controller, 'exclusionCreate').mockReturnThis();
|
||||
|
||||
|
@ -118,14 +154,14 @@ describe('component vnZoneEvents', () => {
|
|||
// });
|
||||
});
|
||||
|
||||
describe('create()', () => {
|
||||
describe('createInclusion()', () => {
|
||||
it('shoud set the selected property and then call the includeDialog show() method', () => {
|
||||
controller.$.includeDialog = {show: jest.fn()};
|
||||
|
||||
const type = 'weekday';
|
||||
const days = [new Date()];
|
||||
const weekday = 1;
|
||||
controller.create(type, days, weekday);
|
||||
controller.createInclusion(type, days, weekday);
|
||||
|
||||
const selection = controller.selected;
|
||||
const firstWeekday = selection.wdays[weekday];
|
||||
|
@ -142,7 +178,7 @@ describe('component vnZoneEvents', () => {
|
|||
const type = 'nonListedType';
|
||||
const days = [new Date()];
|
||||
const weekday = 1;
|
||||
controller.create(type, days, weekday);
|
||||
controller.createInclusion(type, days, weekday);
|
||||
|
||||
const selection = controller.selected;
|
||||
|
||||
|
@ -194,41 +230,32 @@ describe('component vnZoneEvents', () => {
|
|||
});
|
||||
|
||||
describe('onExcludeResponse()', () => {
|
||||
it('should call the exclusionCreate() method', () => {
|
||||
jest.spyOn(controller, 'exclusionCreate').mockReturnThis();
|
||||
|
||||
controller.excludeSelected = {type: 'all'};
|
||||
controller.onExcludeResponse('accept');
|
||||
|
||||
expect(controller.exclusionCreate).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('should call the exclusionGeoCreate() method', () => {
|
||||
jest.spyOn(controller, 'exclusionGeoCreate').mockReturnThis();
|
||||
|
||||
controller.excludeSelected = {type: 'specificLocations'};
|
||||
controller.onExcludeResponse('accept');
|
||||
|
||||
expect(controller.exclusionGeoCreate).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('should call the exclusionDelete() method', () => {
|
||||
jest.spyOn(controller, 'exclusionDelete').mockReturnThis();
|
||||
|
||||
const exclusions = [{id: 1}];
|
||||
controller.exclusions = exclusions;
|
||||
controller.exclusions = [{id: 1}];
|
||||
controller.excludeSelected = {type: 'all'};
|
||||
controller.onExcludeResponse('delete');
|
||||
|
||||
expect(controller.exclusionDelete).toHaveBeenCalledWith(exclusions);
|
||||
});
|
||||
|
||||
it('shoud make an HTTP POST query to create a new one and then call the refresh() method', () => {
|
||||
jest.spyOn(controller, 'refresh').mockReturnThis();
|
||||
|
||||
controller.selected = {id: 1};
|
||||
controller.isNew = true;
|
||||
|
||||
$httpBackend.when('POST', `Zones/1/events`).respond(200);
|
||||
controller.onExcludeResponse('accept');
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.refresh).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('shoud make an HTTP PUT query and then call the refresh() method', () => {
|
||||
jest.spyOn(controller, 'refresh').mockReturnThis();
|
||||
|
||||
controller.selected = {id: 1};
|
||||
controller.isNew = false;
|
||||
|
||||
const eventId = 1;
|
||||
$httpBackend.when('PUT', `Zones/1/events/${eventId}`).respond(200);
|
||||
controller.onExcludeResponse('accept');
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.refresh).toHaveBeenCalledWith();
|
||||
expect(controller.exclusionDelete).toHaveBeenCalledWith(controller.exclusions);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -249,9 +276,10 @@ describe('component vnZoneEvents', () => {
|
|||
it('shoud make an HTTP POST query and then call the refresh() method', () => {
|
||||
jest.spyOn(controller, 'refresh').mockReturnThis();
|
||||
|
||||
const dates = [new Date()];
|
||||
controller.excludeSelected = {};
|
||||
controller.isNew = true;
|
||||
$httpBackend.expect('POST', `Zones/1/exclusions`).respond({id: 1});
|
||||
controller.exclusionCreate(dates);
|
||||
controller.exclusionCreate();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.refresh).toHaveBeenCalledWith();
|
||||
|
|
Loading…
Reference in New Issue