Skip to content

Commit

Permalink
test(vx-event): update test event
Browse files Browse the repository at this point in the history
  • Loading branch information
hshoff authored Aug 20, 2020
1 parent 8af6aa5 commit 60d130d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/vx-event/test/localPoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ describe('localPoint', () => {

test('it should handle localPoint(event) and get node from event.target', () => {
const e = new MouseEvent('test', {
clientX: 0,
clientY: 0,
clientX: 10,
clientY: 10,
});
Object.defineProperty(e, 'target', {
writable: false,
value: {
clientLeft: 0,
clientTop: 0,
clientLeft: 10,
clientTop: 10,
getBoundingClientRect: () => ({ left: 0, top: 0 }),
},
});
// @ts-ignore
const result = localPoint(e);
expect(result).toEqual({ x: 0, y: 0 });
expect(result).toEqual({ x: 10, y: 10 });
});

test('it should handle localPoint(node, event)', () => {
const e = new MouseEvent('test', {
clientX: 0,
clientY: 0,
clientX: 10,
clientY: 10,
});
const node = document.createElementNS('http://www.w3.org/2000/svg', 'path');
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
Expand All @@ -44,6 +44,6 @@ describe('localPoint', () => {
svg.getScreenCTM = () => ({ inverse: () => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] });
svg.appendChild(node);
const result = localPoint(node, e);
expect(result).toEqual({ x: 0, y: 0 });
expect(result).toEqual({ x: 10, y: 10 });
});
});

0 comments on commit 60d130d

Please sign in to comment.