Files
landing-builder/lib/utils/reorder.test.ts
T
2025-11-14 16:40:45 +09:00

24 lines
751 B
TypeScript

import { describe, it, expect } from 'vitest'
import { move } from './reorder'
describe('reorder.move', () => {
it('같은 배열 인스턴스를 변형하지 않고 from→to로 아이템을 이동한다', () => {
const src = ['a', 'b', 'c', 'd']
const out = move(src, 1, 3)
expect(src).toEqual(['a', 'b', 'c', 'd'])
expect(out).toEqual(['a', 'c', 'd', 'b'])
})
it('경계 밖 인덱스는 원본을 그대로 반환한다', () => {
const src = ['x', 'y']
expect(move(src, -1, 1)).toBe(src)
expect(move(src, 0, 5)).toBe(src)
expect(move(src, 2, 0)).toBe(src)
})
it('from과 to가 같으면 원본을 그대로 반환한다', () => {
const src = [1, 2, 3]
expect(move(src, 1, 1)).toBe(src)
})
})