/
uzer_007
/
Rixea
Обзор
Документация
Войти
/
uzer_007
/
Rixea
Код
Запросы
0
Задачи
Вики
Пакеты
5
Релизы
2
CI/CD
Аналитика
Безопасность
master
web_src/js/modules/sortable.test.ts
14 строк
734 B
uzer_007
feat: первая версия Rixea
02 авг 2026, 22:16
02 авг 2026, 22:16
d4f7504
Код
Авторство
О чём код?
import {restoreSortableItem} from './sortable.ts'; test.each([ {original: ['a', 'b', 'c', 'd'], moved: ['a', 'd', 'b', 'c'], item: 'd', oldIndex: 3}, {original: ['a', 'b', 'c', 'd'], moved: ['a', 'c', 'd', 'b'], item: 'b', oldIndex: 1}, {original: ['a', 'b', 'c', 'd'], moved: ['b', 'c', 'd', 'a'], item: 'a', oldIndex: 0}, ])('restores $item to index $oldIndex', ({original, moved, item, oldIndex}) => { document.body.innerHTML = `<div>${moved.map((id) => `<span id="${id}"></span>`).join('')}</div>`; const container = document.body.firstElementChild!; restoreSortableItem(container, document.querySelector(`#${item}`)!, oldIndex); expect(Array.from(container.children, (child) => child.id)).toEqual(original); });