diff --git a/js/actionCreators.js b/js/actionCreators.js index 2edbe737..354f34f8 100644 --- a/js/actionCreators.js +++ b/js/actionCreators.js @@ -95,7 +95,8 @@ export function toggleShuffle() { return { type: TOGGLE_SHUFFLE }; } -const normalize = hrz => hrz / 63 * 100; +export const normalize = hrz => Math.round((hrz - 1) / 63 * 100); + function setEqFromFile(file) { return dispatch => { file.processBuffer(arrayBuffer => { diff --git a/js/actionCreators.test.js b/js/actionCreators.test.js index 9d9b026b..51f5eca7 100644 --- a/js/actionCreators.test.js +++ b/js/actionCreators.test.js @@ -18,7 +18,8 @@ import { setEqBand, setEqToMax, setEqToMin, - setEqToMid + setEqToMid, + normalize } from "./actionCreators"; test("stop", () => { @@ -123,3 +124,8 @@ test("setEqToMid", () => { ]); expect(mockDispatch.mock.calls).toEqual(expectedCalls); }); + +test("normalize", () => { + expect(normalize(1)).toBe(0); + expect(normalize(64)).toBe(100); +});