feat: add testFront
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
4b65b531fd
commit
2b5550bc6e
|
@ -301,13 +301,6 @@ class Controller extends Section {
|
|||
else
|
||||
this.exclusionGeos.delete(geoId);
|
||||
}
|
||||
|
||||
exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return {name: {like: `%${value}%`}};
|
||||
}
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$element', '$scope', 'vnWeekDays'];
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import './index';
|
||||
import crudModel from 'core/mocks/crud-model';
|
||||
|
||||
describe('component vnZoneEvents', () => {
|
||||
let $scope;
|
||||
|
@ -91,7 +92,7 @@ describe('component vnZoneEvents', () => {
|
|||
controller.editMode = 'exclude';
|
||||
controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo);
|
||||
|
||||
expect(controller.editExclusion).toHaveBeenCalledWith();
|
||||
expect(controller.editExclusion).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call the editExclusion() method with exclusionsGeo', () => {
|
||||
|
@ -106,7 +107,7 @@ describe('component vnZoneEvents', () => {
|
|||
controller.editMode = 'exclude';
|
||||
controller.onSelection(days, type, weekday, events, exclusions, exclusionsGeo);
|
||||
|
||||
expect(controller.editExclusion).toHaveBeenCalledWith();
|
||||
expect(controller.editExclusion).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call the createExclusion() method', () => {
|
||||
|
@ -129,8 +130,10 @@ describe('component vnZoneEvents', () => {
|
|||
it('shoud set the excludeSelected.type = "specificLocations" and then call the excludeDialog show() method', () => {
|
||||
controller.$.excludeDialog = {show: jest.fn()};
|
||||
|
||||
controller.exclusionsGeo = [{id: 1}];
|
||||
controller.editExclusion();
|
||||
const exclusionGeos = [{id: 1}];
|
||||
const exclusions = [];
|
||||
|
||||
controller.editExclusion(exclusions, exclusionGeos);
|
||||
|
||||
expect(controller.excludeSelected.type).toEqual('specificLocations');
|
||||
expect(controller.$.excludeDialog.show).toHaveBeenCalledWith();
|
||||
|
@ -139,8 +142,10 @@ describe('component vnZoneEvents', () => {
|
|||
it('shoud set the excludeSelected.type = "all" and then call the excludeDialog show() method', () => {
|
||||
controller.$.excludeDialog = {show: jest.fn()};
|
||||
|
||||
controller.exclusions = [{id: 1}];
|
||||
controller.editExclusion();
|
||||
const exclusionGeos = [];
|
||||
const exclusions = [{id: 1}];
|
||||
|
||||
controller.editExclusion(exclusions, exclusionGeos);
|
||||
|
||||
expect(controller.excludeSelected.type).toEqual('all');
|
||||
expect(controller.$.excludeDialog.show).toHaveBeenCalledWith();
|
||||
|
@ -257,11 +262,10 @@ describe('component vnZoneEvents', () => {
|
|||
it('should call the exclusionDelete() method', () => {
|
||||
jest.spyOn(controller, 'exclusionDelete').mockReturnThis();
|
||||
|
||||
controller.exclusions = [{id: 1}];
|
||||
controller.excludeSelected = {type: 'all'};
|
||||
controller.excludeSelected = {id: 1, type: 'all'};
|
||||
controller.onExcludeResponse('delete');
|
||||
|
||||
expect(controller.exclusionDelete).toHaveBeenCalledWith(controller.exclusions);
|
||||
expect(controller.exclusionDelete).toHaveBeenCalledWith(controller.excludeSelected);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -296,51 +300,41 @@ describe('component vnZoneEvents', () => {
|
|||
it('shoud make an HTTP DELETE query once and then call the refresh() method', () => {
|
||||
jest.spyOn(controller, 'refresh').mockReturnThis();
|
||||
|
||||
const exclusions = [{id: 1}];
|
||||
const exclusions = {id: 1};
|
||||
const firstExclusionId = 1;
|
||||
$httpBackend.when('DELETE', `Zones/1/exclusions/${firstExclusionId}`).respond(200);
|
||||
$httpBackend.expectDELETE(`Zones/1/exclusions/${firstExclusionId}`).respond(200);
|
||||
controller.exclusionDelete(exclusions);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.refresh).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
it('shoud make an HTTP DELETE query for every event and then call the refresh() method', () => {
|
||||
jest.spyOn(controller, 'refresh').mockReturnThis();
|
||||
jest.spyOn(controller.$http, 'delete').mockReturnValue(200);
|
||||
describe('onSearch()', () => {
|
||||
it('should call the applyFilter() method and then set the data', () => {
|
||||
jest.spyOn(controller, 'getChecked').mockReturnValue([1, 2, 3]);
|
||||
|
||||
const exclusions = [{id: 1}, {id: 2}, {id: 3}, {id: 4}];
|
||||
controller.exclusionDelete(exclusions);
|
||||
$scope.$apply();
|
||||
controller.$.treeview = {};
|
||||
controller.$.model = crudModel;
|
||||
controller.excludeSelected = {type: 'specificLocations'};
|
||||
controller._excludeSearch = 'es';
|
||||
|
||||
expect(controller.$http.delete).toHaveBeenCalledTimes(4);
|
||||
expect(controller.refresh).toHaveBeenCalledWith();
|
||||
controller.onSearch();
|
||||
const treeviewData = controller.$.treeview.data;
|
||||
|
||||
expect(treeviewData).toBeDefined();
|
||||
expect(treeviewData.length).toEqual(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('exclusionGeoDelete()', () => {
|
||||
it('shoud make an HTTP DELETE query twice and then call the refresh() method', () => {
|
||||
jest.spyOn(controller, 'refresh').mockReturnThis();
|
||||
describe('onFetch()', () => {
|
||||
it('should call the applyFilter() method and then return the model data', () => {
|
||||
jest.spyOn(controller, 'getChecked').mockReturnValue([1, 2, 3]);
|
||||
|
||||
const exclusionsGeo = [{id: 1}];
|
||||
const firstExclusionGeoId = 1;
|
||||
$httpBackend.when('DELETE', `Zones/1/exclusions/${firstExclusionGeoId}`).respond(200);
|
||||
controller.exclusionDelete(exclusionsGeo);
|
||||
$httpBackend.flush();
|
||||
controller.$.model = crudModel;
|
||||
const result = controller.onFetch();
|
||||
|
||||
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();
|
||||
expect(result.length).toEqual(3);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue