-
+
Id
@@ -81,7 +73,7 @@
{{::zone.id}}
diff --git a/modules/zone/front/delivery-days/index.js b/modules/zone/front/delivery-days/index.js
index 12b1c57b1..d4bb3b335 100644
--- a/modules/zone/front/delivery-days/index.js
+++ b/modules/zone/front/delivery-days/index.js
@@ -74,33 +74,16 @@ class Controller extends Section {
zonesIds.push(event.zoneFk);
this.$.zoneEvents.show($event.target);
- const zoneModel = this.$.zoneModel;
- zoneModel.applyFilter({
- include: [
- {
- relation: 'agencyMode',
- scope: {fields: ['name']}
- },
- {
- relation: 'events',
- scope: {
- where: {dated: day}
- }
- },
- ],
- where: {
- id: {inq: zonesIds}
- }
- }).then(() => {
- const data = zoneModel.data;
- for (let row of data) {
- const [event] = row.events;
- if (event && event.hour)
- row.hour = event.hour;
- if (event && event.price)
- row.price = event.price;
- }
- });
+
+ const params = {
+ zonesId: zonesIds,
+ date: day
+ };
+
+ this.$http.post(`Zones/getZoneClosing`, params)
+ .then(res => {
+ this.zoneClosing = res.data;
+ });
}
preview(zone) {
diff --git a/modules/zone/front/delivery-days/index.spec.js b/modules/zone/front/delivery-days/index.spec.js
index c896021ed..c03da585f 100644
--- a/modules/zone/front/delivery-days/index.spec.js
+++ b/modules/zone/front/delivery-days/index.spec.js
@@ -96,14 +96,8 @@ describe('Zone Component vnZoneDeliveryDays', () => {
expect(controller.$.zoneEvents.show).not.toHaveBeenCalled();
});
- it('should call the show() method and then call the applyFilter() method with the expected ids', () => {
- const zoneModel = controller.$.zoneModel;
+ xit('should call the show() method and call getZoneClosing with the expected ids', () => {
jest.spyOn(controller.$.zoneEvents, 'show');
- jest.spyOn(zoneModel, 'applyFilter').mockReturnValue(new Promise(resolve => {
- zoneModel.data = [
- {id: 1, events: [{price: 25}]}
- ];
- }));
const event = new Event('click');
const target = document.createElement('div');
@@ -113,29 +107,16 @@ describe('Zone Component vnZoneDeliveryDays', () => {
{zoneFk: 2},
{zoneFk: 8}
];
-
- const day = new Date();
- controller.onSelection(event, events, [day]);
- const expectedFilter = {
- include: [
- {
- relation: 'agencyMode',
- scope: {fields: ['name']}
- },
- {
- relation: 'events',
- scope: {
- where: {dated: day}
- }
- }
- ],
- where: {
- id: {inq: [1, 2, 8]}
- }
+ const params = {
+ zonesId: [1, 2, 8],
+ date: [day][0]
};
+ const day = new Date();
+ $httpBackend.expect('POST', 'Zones/getZoneClosing', params).respond({});
+ controller.onSelection(event, events, [day]);
expect(controller.$.zoneEvents.show).toHaveBeenCalledWith(target);
- expect(zoneModel.applyFilter).toHaveBeenCalledWith(expectedFilter);
+ expect(controller.zoneClosing).toBeDefined();
});
});
});