Skip to content

Commit 770c990

Browse files
committed
Add pointer test
1 parent 14ada45 commit 770c990

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/vue-split-panel/src/composables/use-pointer.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,28 @@ describe('usePointer', () => {
225225
expect(sizePercentage.value).toBe(25); // 100/400 * 100 = 25%
226226
});
227227

228+
it('should compose RTL and primary end correctly (double mirror)', async () => {
229+
// Horizontal, RTL and primary=end cause two mirrors:
230+
// 1) RTL: position -> 400 - x
231+
// 2) primary=end: position -> 400 - position
232+
// Net effect: original x (double mirror cancels out)
233+
options.direction = ref('rtl');
234+
options.orientation = ref('horizontal');
235+
options.primary = ref('end');
236+
usePointer(collapsed, sizePercentage, sizePixels, options);
237+
238+
mockDragX.value = 100; // Expect net position = 100
239+
await nextTick();
240+
expect(sizePercentage.value).toBe(25); // 100/400 * 100 = 25%
241+
242+
// Also verify snapping respects net position
243+
options.snapPixels = computed(() => [100]);
244+
options.snapThreshold = ref(5);
245+
mockDragX.value = 102; // Within threshold of 100
246+
await nextTick();
247+
expect(sizePercentage.value).toBe(25); // snapped to 100 -> 25%
248+
});
249+
228250
it('should clamp sizePercentage between 0 and 100', async () => {
229251
usePointer(collapsed, sizePercentage, sizePixels, options);
230252

0 commit comments

Comments
 (0)