/
githubmr
/
facebook-react
Обзор
Документация
Войти
/
githubmr
/
facebook-react
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-devtools-timeline/src/view-base/utils/__tests__/clamp-test.js
29 строк
765 B
Ricky
Add jest lint rules (#29760)
10 июн 2024, 21:31
Не верифицирован
10 июн 2024, 21:31
d172bda
Код
Авторство
О чём код?
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import {clamp} from '../clamp'; describe('clamp', () => { it('should return min if value < min', () => { expect(clamp(0, 1, -1)).toBe(0); expect(clamp(0.1, 1.1, 0.05)).toBe(0.1); }); it('should return value if min <= value <= max', () => { expect(clamp(0, 1, 0)).toBe(0); expect(clamp(0, 1, 0.5)).toBe(0.5); expect(clamp(0, 1, 1)).toBe(1); expect(clamp(0.1, 1.1, 0.15)).toBe(0.15); }); it('should return max if max < value', () => { expect(clamp(0, 1, 2)).toBe(1); expect(clamp(0.1, 1.1, 1.15)).toBe(1.1); }); });