/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/core-data/src/utils/test/with-weak-map-cache.js
24 строки
602 B
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import withWeakMapCache from '../with-weak-map-cache'; describe( 'withWeakMapCache', () => { it( 'calls and returns from the original function', () => { const cachedFn = withWeakMapCache( () => 'Called' ); const result = cachedFn(); expect( result ).toBe( 'Called' ); } ); it( 'caches by weak reference', () => { const a = {}; const b = {}; const fn = jest.fn().mockReturnValue( 'Called' ); const cachedFn = withWeakMapCache( fn ); cachedFn( a ); cachedFn( a ); expect( fn ).toHaveBeenCalledTimes( 1 ); cachedFn( b ); expect( fn ).toHaveBeenCalledTimes( 2 ); } ); } );