From 25b7291a49d81431ef6b15b7045cd223e18bf92d Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Fri, 18 Aug 2023 09:15:52 +0200 Subject: [PATCH] test: simplified tests --- .../__tests__/addToTotalIfNumber.js | 41 ++++++------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/src/modules/pivotTable/__tests__/addToTotalIfNumber.js b/src/modules/pivotTable/__tests__/addToTotalIfNumber.js index 6c3531821..577f6e778 100644 --- a/src/modules/pivotTable/__tests__/addToTotalIfNumber.js +++ b/src/modules/pivotTable/__tests__/addToTotalIfNumber.js @@ -1,89 +1,76 @@ import { addToTotalIfNumber } from '../addToTotalIfNumber.js' -const field = 'test' const tests = [ { testName: 'negative value', value: -1, - totalObj: {}, - field, + total: undefined, expected: -1, }, { testName: 'zero value', value: 0, - totalObj: {}, - field, + total: undefined, expected: 0, }, { testName: 'positive value', value: 1, - totalObj: {}, - field, + total: undefined, expected: 1, }, { testName: 'null value', value: null, - totalObj: {}, - field, + total: undefined, expected: undefined, }, { testName: 'undefined value', value: undefined, - totalObj: {}, - field, + total: undefined, expected: undefined, }, { testName: 'string value', value: 'string', - totalObj: {}, - field, + total: undefined, expected: undefined, }, { testName: 'negative value with existing total', value: -1, - totalObj: { [field]: 100 }, - field, + total: 100, expected: 99, }, { testName: 'zero value with existing total', value: 0, - totalObj: { [field]: 100 }, - field, + total: 100, expected: 100, }, { testName: 'positive value with existing total', value: 1, - totalObj: { [field]: 100 }, - field, + total: 100, expected: 101, }, { testName: 'null value with existing total', value: null, - totalObj: { [field]: 100 }, - field, + total: 100, expected: 100, }, { testName: 'undefined value with existing total', value: undefined, - totalObj: { [field]: 100 }, - field, + total: 100, expected: 100, }, { testName: 'string value with existing total', value: 'string', - totalObj: { [field]: 100 }, - field, + total: 100, expected: 100, }, ] @@ -91,9 +78,7 @@ const tests = [ describe('addToTotalIfNumber', () => { tests.forEach((t) => { it(t.testName, () => { - expect(addToTotalIfNumber(t.value, t.totalObj[t.field])).toEqual( - t.expected - ) + expect(addToTotalIfNumber(t.value, t.total)).toEqual(t.expected) }) }) })