/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
packages/mui-utils/src/setRef/setRef.test.ts
38 строк
864 B
Jan Potoms
[code-infra] Remove a few ts-ignore comments (#43265)
17 апр 2026, 19:14
Не верифицирован
17 апр 2026, 19:14
9b741fd
Код
Авторство
О чём код?
import * as React from 'react'; import { expect } from 'chai'; import { spy } from 'sinon'; import setRef from './setRef'; describe('setRef', () => { it('can handle callback refs', () => { const ref = spy(); const instance = 'proxy'; setRef(ref, instance); expect(ref.called).to.equal(true); expect(ref.firstCall.args[0]).to.equal(instance); }); it('can handle ref objects', () => { const ref = React.createRef(); const instance = 'proxy'; setRef(ref, instance); expect(ref.current).to.equal(instance); }); it('ignores falsy refs without errors', () => { const instance = 'proxy'; // all no-ops setRef(undefined, instance); setRef(null, instance); }); it('throws on legacy string refs', () => { // @ts-expect-error expect(() => setRef('stringRef1', 'proxy')).to.throw(); }); });