From 01b7661d2e8063a38b234a49b6cddffbc1df2b91 Mon Sep 17 00:00:00 2001 From: brianlund-wandb Date: Fri, 13 Dec 2024 11:34:13 -0800 Subject: [PATCH] tslint issues --- .../components/elements/SliderInput.test.tsx | 51 ++++++++++--------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/weave-js/src/common/components/elements/SliderInput.test.tsx b/weave-js/src/common/components/elements/SliderInput.test.tsx index ae002fb36ba..a712fefc354 100644 --- a/weave-js/src/common/components/elements/SliderInput.test.tsx +++ b/weave-js/src/common/components/elements/SliderInput.test.tsx @@ -2,57 +2,62 @@ import {getClosestTick} from './SliderInput'; describe('getClosestTick', () => { test('lower previous value returns next greater', () => { - let ticks = [...new Set([2, 4, 6, 8, 10])], - previous = 4, - val = 5; - + const ticks = [2, 4, 6, 8, 10]; + const previous = 4; + const val = 5; expect(getClosestTick(ticks, val, previous)).toBe(6); }); + test('lower previous value returns next greater, large step', () => { + const ticks = [2, 4, 60, 80, 10]; + const previous = 4; + const val = 5; + expect(getClosestTick(ticks, val, previous)).toBe(60); + }); test('greater previous value returns next lesser', () => { - let ticks = [...new Set([2, 4, 6, 8, 10])], - previous = 4, - val = 3; + const ticks = [2, 4, 6, 8, 10]; + const previous = 4; + const val = 3; const actual = getClosestTick(ticks, val, previous); expect(actual).toBe(2); }); test('greater previous value returns next lesser, consecutive', () => { - let ticks = [...new Set([1, 2, 3, 4, 5, 6])], - previous = 4, - val = 3; + const ticks = [1, 2, 3, 4, 5, 6]; + const previous = 4; + const val = 3; const actual = getClosestTick(ticks, val, previous); expect(actual).toBe(3); }); test('lower previous value returns next greater, consecutive', () => { - let ticks = [...new Set([1, 2, 3, 4, 5, 6])], - previous = 3, - val = 4; + const ticks = [1, 2, 3, 4, 5, 6]; + const previous = 3; + const val = 4; const actual = getClosestTick(ticks, val, previous); expect(actual).toBe(4); }); test('lower previous value returns next greater, erratic', () => { - let ticks = [...new Set([1, 4, 5, 7, 9, 12])], - previous = 9, - val = 10; + const ticks = [1, 4, 5, 7, 9, 12]; + const previous = 9; + const val = 10; const actual = getClosestTick(ticks, val, previous); expect(actual).toBe(12); }); test('greater previous value returns next lower, erratic', () => { - let ticks = [...new Set([1, 2, 5, 7, 9, 12])], - previous = 5, - val = 4; + const ticks = [1, 2, 5, 7, 9, 12]; + const previous = 5; + const val = 4; const actual = getClosestTick(ticks, val, previous); expect(actual).toBe(2); }); // Modified logic, retaining for expected performance test('large number of ticks', () => { - let ticks = [...new Set()], - previous = 500000, - val = 500001; - + const ticks = []; for (let i = 0; i < 10000000; i += 2) { ticks.push(i); } + + const previous = 500000; + const val = 500001; const start = Date.now(); const actual = getClosestTick(ticks, val, previous); const end = Date.now();