/
githubmirror
/
wp-calypso
Обзор
Документация
Войти
/
githubmirror
/
wp-calypso
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/js-utils/src/test/map-values.ts
22 строки
855 B
Griffith Chen
Remove lodash mapValues, pickBy, and omitBy in favor of @automattic/js-utils (#111739)
17 июн 2026, 08:32
Не верифицирован
17 июн 2026, 08:32
9ee3ece
Код
Авторство
О чём код?
import mapValues from '../map-values'; describe( 'mapValues', () => { it( 'maps each value, passing value and key to the iteratee', () => { expect( mapValues( { a: 1, b: 2 }, ( value, key ) => `${ key }${ value }` ) ).toStrictEqual( { a: 'a1', b: 'b2', } ); } ); it( 'returns an empty object for a nullish source', () => { const nullable: Record< string, number > | null | undefined = null; expect( mapValues( nullable, ( value ) => value ) ).toStrictEqual( {} ); } ); it( 'keeps an own `__proto__` key as data without polluting the prototype', () => { const input = JSON.parse( '{ "__proto__": { "polluted": true }, "a": 1 }' ); const result = mapValues( input, ( value ) => value ); expect( Object.getPrototypeOf( result ) ).toBe( Object.prototype ); expect( Object.hasOwn( result, '__proto__' ) ).toBe( true ); } ); } );