Added tests
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
63ed592312
commit
fa73911452
|
@ -6,12 +6,20 @@ class Controller extends Section {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
this.vnWeekDays = vnWeekDays;
|
this.vnWeekDays = vnWeekDays;
|
||||||
this.editMode = 'include';
|
this.editMode = 'include';
|
||||||
|
}
|
||||||
|
|
||||||
this.path = `Zones/${this.$params.id}/events`;
|
$onInit() {
|
||||||
this.exclusionsPath = `Zones/${this.$params.id}/exclusions`;
|
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get path() {
|
||||||
|
return `Zones/${this.$params.id}/events`;
|
||||||
|
}
|
||||||
|
|
||||||
|
get exclusionsPath() {
|
||||||
|
return `Zones/${this.$params.id}/exclusions`;
|
||||||
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
let data = {};
|
let data = {};
|
||||||
this.$q.all([
|
this.$q.all([
|
||||||
|
|
|
@ -0,0 +1,103 @@
|
||||||
|
import './index';
|
||||||
|
|
||||||
|
describe('component vnZoneEvents', () => {
|
||||||
|
let $scope;
|
||||||
|
let controller;
|
||||||
|
let $httpBackend;
|
||||||
|
let $httpParamSerializer;
|
||||||
|
|
||||||
|
beforeEach(ngModule('zone'));
|
||||||
|
|
||||||
|
beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
|
||||||
|
$httpBackend = _$httpBackend_;
|
||||||
|
$httpParamSerializer = _$httpParamSerializer_;
|
||||||
|
$scope = $rootScope.$new();
|
||||||
|
const $element = angular.element(`<vn-zone-events></vn-zone-events>`);
|
||||||
|
controller = $componentController('vnZoneEvents', {$element, $scope});
|
||||||
|
controller.$params = {id: 1};
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('refresh()', () => {
|
||||||
|
it('should set the zone and then call both getSummary() and getWarehouses()', () => {
|
||||||
|
$httpBackend.expectGET(`Zones/1/events`).respond({id: 1});
|
||||||
|
$httpBackend.expectGET(`Zones/1/exclusions`).respond({id: 1});
|
||||||
|
controller.refresh();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
const data = controller.$.data;
|
||||||
|
|
||||||
|
expect(data.events).toBeDefined();
|
||||||
|
expect(data.exclusions).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('onSelection()', () => {
|
||||||
|
it('should call the edit() method', () => {
|
||||||
|
jest.spyOn(controller, 'edit').mockReturnThis();
|
||||||
|
|
||||||
|
const weekday = {};
|
||||||
|
const days = [];
|
||||||
|
const type = 'EventType';
|
||||||
|
const events = [{name: 'Event'}];
|
||||||
|
const exclusions = [];
|
||||||
|
controller.editMode = 'include';
|
||||||
|
controller.onSelection(days, type, weekday, events, exclusions);
|
||||||
|
|
||||||
|
expect(controller.edit).toHaveBeenCalledWith({name: 'Event'});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call the create() method', () => {
|
||||||
|
jest.spyOn(controller, 'create').mockReturnThis();
|
||||||
|
|
||||||
|
const weekday = {dated: new Date()};
|
||||||
|
const days = [weekday];
|
||||||
|
const type = 'EventType';
|
||||||
|
const events = [];
|
||||||
|
const exclusions = [];
|
||||||
|
controller.editMode = 'include';
|
||||||
|
controller.onSelection(days, type, weekday, events, exclusions);
|
||||||
|
|
||||||
|
expect(controller.create).toHaveBeenCalledWith(type, days, weekday);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call the exclusionDelete() method', () => {
|
||||||
|
jest.spyOn(controller, 'exclusionDelete').mockReturnThis();
|
||||||
|
|
||||||
|
const weekday = {};
|
||||||
|
const days = [];
|
||||||
|
const type = 'EventType';
|
||||||
|
const events = [];
|
||||||
|
const exclusions = [{id: 1}];
|
||||||
|
controller.editMode = 'delete';
|
||||||
|
controller.onSelection(days, type, weekday, events, exclusions);
|
||||||
|
|
||||||
|
expect(controller.exclusionDelete).toHaveBeenCalledWith(exclusions);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call the exclusionCreate() method', () => {
|
||||||
|
jest.spyOn(controller, 'exclusionCreate').mockReturnThis();
|
||||||
|
|
||||||
|
const weekday = {};
|
||||||
|
const days = [{dated: new Date()}];
|
||||||
|
const type = 'EventType';
|
||||||
|
const events = [];
|
||||||
|
const exclusions = [];
|
||||||
|
controller.editMode = 'delete';
|
||||||
|
controller.onSelection(days, type, weekday, events, exclusions);
|
||||||
|
|
||||||
|
expect(controller.exclusionCreate).toHaveBeenCalledWith(days);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('onDeleteResponse()', () => {
|
||||||
|
it('', () => { });
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('exclusionCreate()', () => {
|
||||||
|
it('', () => { });
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('exclusionDelete()', () => {
|
||||||
|
it('', () => { });
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue