From 3f09a91147accf0d8d84cebaa0679674731e4e4a Mon Sep 17 00:00:00 2001 From: Jason Matthias Date: Thu, 13 Jun 2019 12:37:46 -0700 Subject: [PATCH 1/2] add logic to return error if index chosen for burst capture not valid expression type --- src/lib/calc-helpers.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/calc-helpers.js b/src/lib/calc-helpers.js index 57cda8c..635d988 100644 --- a/src/lib/calc-helpers.js +++ b/src/lib/calc-helpers.js @@ -27,10 +27,14 @@ export const getImageData = opts => */ const getExpByIndex = idx => calculator.getExpressions()[idx - 1]; -// Returns an error message on failure. +/** + * Returns an error message on failure. + * Skips expressions that are not of type 'expression' + */ export const setSliderByIndex = (idx, val) => { const exp = getExpByIndex(idx); if (!exp) return noSuchExpression(idx); + if (exp.type !== 'expression') return notASlider(idx); const { id, latex } = exp; const match = latex.match(/(.+)=/); From 6966d036a4d5f4a754c0f67d9548f818f11c5695 Mon Sep 17 00:00:00 2001 From: Jason Matthias Date: Thu, 20 Jun 2019 15:31:19 -0700 Subject: [PATCH 2/2] modified calculator mock functions to pass tests --- src/actions/action-creators.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/actions/action-creators.test.js b/src/actions/action-creators.test.js index dd752b5..cdd477b 100644 --- a/src/actions/action-creators.test.js +++ b/src/actions/action-creators.test.js @@ -45,7 +45,10 @@ const desmosMock = { GraphingCalculator: jest.fn(() => { return { asyncScreenshot: (opts, cb) => cb(''), - getExpressions: () => [{ id: 1, latex: 'x = 3' }, { id: 2, latex: '' }], + getExpressions: () => [ + { id: 1, type: 'expression', latex: 'x = 3' }, + { id: 2, latex: '' } + ], setExpression: () => null }; })