From a528161b93b33048173b02f0aced6171d62d15d0 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 7 Jan 2022 08:08:41 +0100 Subject: [PATCH] refactor(supplier.summary): separate isFarmer() --- modules/supplier/front/summary/index.js | 12 ++++++++---- modules/supplier/front/summary/index.spec.js | 8 ++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/supplier/front/summary/index.js b/modules/supplier/front/summary/index.js index 14c030da0..85268a13d 100644 --- a/modules/supplier/front/summary/index.js +++ b/modules/supplier/front/summary/index.js @@ -17,12 +17,16 @@ class Controller extends Summary { getSummary() { return this.$http.get(`Suppliers/${this.supplier.id}/getSummary`).then(response => { this.summary = response.data; - - this.summary.isFarmer = false; - if(response.data.sageWithholdingFk == 2) - this.summary.isFarmer = true; + this.isFarmer(response.data.sageWithholdingFk); }); } + + isFarmer(sageWithholdingFk) { + const farmerCode = 2; + + if (sageWithholdingFk == farmerCode) + this.summary.isFarmer = true; + } } ngModule.vnComponent('vnSupplierSummary', { diff --git a/modules/supplier/front/summary/index.spec.js b/modules/supplier/front/summary/index.spec.js index a1e418670..7295a028c 100644 --- a/modules/supplier/front/summary/index.spec.js +++ b/modules/supplier/front/summary/index.spec.js @@ -1,6 +1,6 @@ import './index'; -describe('Supplier', () => { +fdescribe('Supplier', () => { describe('Component vnSupplierSummary', () => { let controller; let $httpBackend; @@ -15,7 +15,7 @@ describe('Supplier', () => { controller = $componentController('vnSupplierSummary', {$element, $scope}); })); - describe('getSummary()', () => { + fdescribe('getSummary()', () => { it('should perform a get asking for the supplier data', () => { controller.supplier = {id: 1}; @@ -25,11 +25,11 @@ describe('Supplier', () => { controller.getSummary(); $httpBackend.flush(); - expect(controller.summary).toEqual({id: 1, isFarmer: false}); + expect(controller.summary).toEqual({id: 1}); }); it('should get if supplier is farmer by sageWithholdingFk', () => { - controller.supplier = {id: 2}; + controller.supplier = {id: 2, sageWithholdingFk: 2}; const query = `Suppliers/${controller.supplier.id}/getSummary`;