Skip to content

Commit

Permalink
task(HTL-112171): Update unit test and comment
Browse files Browse the repository at this point in the history
  • Loading branch information
coolestKev committed Dec 17, 2024
1 parent 0ed8b53 commit 80616b7
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions packages/core/src/Drawer/hooks/useSnap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,14 @@ describe('Drawer snap hook unit test', () => {
test('Snap position initialized correctly', () => {
const { result } = renderHook(() => useSnap(['0%', '20%', '30%'], ['100%', '100%', '100%']))
const { snapPosition, handleSnap } = result.current
expect(snapPosition).toBe('0%')
expect(snapPosition).toBe('20%')

// Scroll all the way up, and back down should return to original position
// To middle
handleSnap('', { offset: { y: 0 } })
// Start middle, scroll up and scroll down should be back to initial position
// Scroll to top
handleSnap('', { offset: { y: 101 } })

// To top
handleSnap('', { offset: { y: 101 } })

// Back to middle
// Scroll back to middle
handleSnap('', { offset: { y: -101 } })

// Back to bottom
handleSnap('', { offset: { y: -101 } })
expect(snapPosition).toBe('0%')
expect(snapPosition).toBe('20%')
})
})

0 comments on commit 80616b7

Please sign in to comment.