mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-07 01:21:37 +00:00
* feat(web): support composer attachment drag reordering * fix(web): handle forward attachment reordering * fix(web): enlarge file attachment touch targets * fix(web): preserve staged attachment order
20 lines
974 B
TypeScript
20 lines
974 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { moveAttachmentId, orderItemsById, reconcileAttachmentOrder } from './attachmentOrder'
|
|
|
|
describe('attachment order helpers', () => {
|
|
it('keeps existing order while appending newly added attachments', () => {
|
|
expect(reconcileAttachmentOrder(['b', 'stale', 'a'], ['a', 'b', 'c'])).toEqual(['b', 'a', 'c'])
|
|
})
|
|
|
|
it('moves an attachment immediately before the drop target', () => {
|
|
expect(moveAttachmentId(['a', 'b', 'c'], 'a', 'c')).toEqual(['b', 'a', 'c'])
|
|
expect(moveAttachmentId(['a', 'b', 'c'], 'c', 'a')).toEqual(['c', 'a', 'b'])
|
|
expect(moveAttachmentId(['a', 'b', 'c'], 'a', 'b', 'after')).toEqual(['b', 'a', 'c'])
|
|
})
|
|
|
|
it('orders objects without dropping ids unknown to the order list', () => {
|
|
const items = [{ id: 'a' }, { id: 'b' }, { id: 'c' }]
|
|
expect(orderItemsById(items, ['c', 'a'])).toEqual([{ id: 'c' }, { id: 'a' }, { id: 'b' }])
|
|
})
|
|
})
|