/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
packages/mui-material/src/internal/animate.test.js
67 строк
2 KB
Jan Potoms
Update dependencies to resolve Dependabot security alerts (#48641)
09 июн 2026, 16:01
Не верифицирован
09 июн 2026, 16:01
0798f38
Код
Авторство
О чём код?
import { expect } from 'chai'; import { isJsdom } from '@mui/internal-test-utils/env'; import animate from './animate'; const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); const isFirefox = /firefox/i.test(navigator.userAgent); const isJSDOM = isJsdom(); // Firefox in Vitest browser mode reports fractional `scrollLeft` values, so the exact // integer assertions below fail. See https://github.com/vitest-dev/vitest/issues/9223 describe.skipIf(isJSDOM || isSafari || isFirefox)('animate', () => { let container; beforeAll(function beforeHook() { container = document.createElement('div'); container.style.cssText = [ 'height: 100px', 'width: 100px', 'overflow: scroll', 'border: 1px solid #000', ].join(';'); const box = document.createElement('div'); box.style.cssText = ['height: 100px', 'width: 1000px'].join(';'); container.appendChild(box); document.body.appendChild(container); }); afterAll(() => { if (container !== undefined) { document.body.removeChild(container); } }); it('should work', () => new Promise((done) => { container.scrollLeft = 200; expect(container.scrollLeft).to.equal(200); animate('scrollLeft', container, 300, {}, (err) => { expect(err).to.equal(null); expect(container.scrollLeft).to.equal(300); done(); }); })); it('should work when asking for the current value', () => new Promise((done) => { container.scrollLeft = 200; expect(container.scrollLeft).to.equal(200); animate('scrollLeft', container, 200, {}, (err) => { expect(err.message).to.equal('Element already at target position'); expect(container.scrollLeft).to.equal(200); done(); }); })); it('should be able to cancel the animation', () => new Promise((done) => { container.scrollLeft = 200; expect(container.scrollLeft).to.equal(200); const cancel = animate('scrollLeft', container, 300, {}, (err) => { expect(err.message).to.equal('Animation cancelled'); expect(container.scrollLeft).to.equal(200); done(); }); cancel(); })); });