Skip to content

Commit

Permalink
test(vx-event): fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hshoff committed Aug 20, 2020
1 parent 60d130d commit fedc82a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/vx-event/test/localPoint.test.ts
@@ -1,3 +1,4 @@
import { Point } from '@vx/point';
import { localPoint } from '../src';
import localPointGeneric from '../src/localPointGeneric';

Expand All @@ -21,14 +22,14 @@ describe('localPoint', () => {
Object.defineProperty(e, 'target', {
writable: false,
value: {
clientLeft: 10,
clientTop: 10,
clientLeft: 0,
clientTop: 0,
getBoundingClientRect: () => ({ left: 0, top: 0 }),
},
});
// @ts-ignore
const result = localPoint(e);
expect(result).toEqual({ x: 10, y: 10 });
expect(result).toEqual(new Point({ x: 10, y: 10 }));
});

test('it should handle localPoint(node, event)', () => {
Expand All @@ -39,11 +40,11 @@ describe('localPoint', () => {
const node = document.createElementNS('http://www.w3.org/2000/svg', 'path');
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
// @ts-ignore
svg.createSVGPoint = () => ({ matrixTransform: () => ({ x: 0, y: 0 }) });
svg.createSVGPoint = () => ({ matrixTransform: () => ({ x: 10, y: 10 }) });
// @ts-ignore
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: 10, y: 10 });
expect(result).toEqual(new Point({ x: 10, y: 10 }));
});
});

0 comments on commit fedc82a

Please sign in to comment.