/
kaws
/
ui-kit-ce
Обзор
Документация
Войти
/
kaws
/
ui-kit-ce
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/utils/src/getPathValue/getPathValue.test.ts
67 строк
1 KB
Denis Svyatovets
v1.10.0
27 мар 2024, 13:48
27 мар 2024, 13:48
c9029ae
Код
Авторство
О чём код?
import { getPathValue } from './getPathValue' describe('getPathValue', () => { const pathValuesCases = { table: { someData: 1, }, head: { cell: { cellData: 'it is cell object', }, row: { rowData: 'it is row object', }, }, body: { bodyRow: { bodyCell: { bodyCellData: 'it is cell in body object', }, }, }, } const cases = [ { path: ['table'], expected: { someData: 1, }, }, { path: 'table', expected: { someData: 1, }, }, { path: ['head', 'cell'], expected: { cellData: 'it is cell object', }, }, { path: ['body', 'bodyRow', 'bodyCell', 'bodyCellData'], expected: 'it is cell in body object', }, { path: [], expected: pathValuesCases, }, { path: ['noExisting'], expected: undefined, }, { path: 'somePath', expected: undefined, }, ] cases.forEach(({ path, expected }) => { it(`Найденный объект`, () => { expect(getPathValue(pathValuesCases, path)).toEqual(expected) }) }) })