refactor(supplier.summary): separate isFarmer()
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2022-01-07 08:08:41 +01:00
parent 19a6b55a72
commit a528161b93
2 changed files with 12 additions and 8 deletions

View File

@ -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', {

View File

@ -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`;