Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Mar 30, 2024
1 parent 36106fb commit 5af7098
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 130 deletions.
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^10.0.2",
"@semantic-release/npm": "^12.0.0",
"@semantic-release/release-notes-generator": "^12.1.0",
"@semantic-release/release-notes-generator": "^13.0.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.30",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"@types/node": "^20.12.2",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"cp-cli": "^2.0.0",
"del": "^7.1.0",
"del-cli": "^5.1.0",
Expand All @@ -59,8 +59,8 @@
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"rollup": "^4.13.0",
"semantic-release": "^23.0.5",
"rollup": "^4.13.2",
"semantic-release": "^23.0.6",
"serve": "^14.2.1",
"ts-jest": "^29.1.2",
"tslib": "^2.6.2",
Expand All @@ -74,6 +74,9 @@
"ts",
"js"
],
"setupFiles": [
"jest-canvas-mock"
],
"testEnvironment": "jsdom",
"testEnvironmentOptions": {
"resources": "usable",
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/signature_pad.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ exports[`#toSVG returns SVG image with backgroundColor 1`] = `"<svg xmlns="http:

exports[`#toSVG returns SVG image with high DPI 1`] = `"<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 300 150" width="300" height="150"><circle r="1.5" cx="125" cy="54" fill="black"></circle><circle r="1.5" cx="175" cy="54" fill="black"></circle><path d="M 83.000,57.000 C 83.174,60.510 84.000,60.000 85.000,63.000" stroke-width="5.508" stroke="black" fill="none" stroke-linecap="round"></path><path d="M 85.000,63.000 C 89.060,68.048 88.674,68.010 94.000,72.000" stroke-width="4.407" stroke="black" fill="none" stroke-linecap="round"></path><path d="M 94.000,72.000 C 99.488,75.519 99.060,76.048 105.000,79.000" stroke-width="3.402" stroke="black" fill="none" stroke-linecap="round"></path><path d="M 105.000,79.000 C 108.700,82.157 108.988,81.519 113.000,84.000" stroke-width="3.497" stroke="black" fill="none" stroke-linecap="round"></path><path d="M 113.000,84.000 C 119.500,86.000 119.200,86.657 126.000,88.000" stroke-width="3.228" stroke="black" fill="none" stroke-linecap="round"></path><path d="M 126.000,88.000 C 132.402,90.416 132.500,90.000 139.000,92.000" stroke-width="3.211" stroke="black" fill="none" stroke-linecap="round"></path><path d="M 139.000,92.000 C 144.961,93.475 144.902,93.416 151.000,94.000" stroke-width="3.258" stroke="black" fill="none" stroke-linecap="round"></path><path d="M 151.000,94.000 C 156.569,94.652 156.461,94.475 162.000,94.000" stroke-width="3.366" stroke="black" fill="none" stroke-linecap="round"></path><path d="M 162.000,94.000 C 168.992,92.460 169.069,93.152 176.000,91.000" stroke-width="3.078" stroke="black" fill="none" stroke-linecap="round"></path><path d="M 176.000,91.000 C 181.072,90.285 180.992,89.960 186.000,89.000" stroke-width="3.372" stroke="black" fill="none" stroke-linecap="round"></path><path d="M 186.000,89.000 C 192.582,87.232 192.572,87.285 199.000,85.000" stroke-width="3.133" stroke="black" fill="none" stroke-linecap="round"></path><path d="M 199.000,85.000 C 204.297,83.565 204.082,83.232 209.000,81.000" stroke-width="3.290" stroke="black" fill="none" stroke-linecap="round"></path><path d="M 209.000,81.000 C 215.334,77.407 215.297,77.565 221.000,73.000" stroke-width="3.113" stroke="black" fill="none" stroke-linecap="round"></path><path d="M 221.000,73.000 C 224.115,70.107 224.334,70.407 227.000,67.000" stroke-width="3.535" stroke="black" fill="none" stroke-linecap="round"></path></svg>"`;

exports[`user interactions allows user to paint on the pad 1`] = `"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMzAwIDE1MCIgd2lkdGg9IjMwMCIgaGVpZ2h0PSIxNTAiPjwvc3ZnPg=="`;
exports[`user interactions allows user to paint on the pad 1`] = `"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgMzAwIDE1MCIgd2lkdGg9IjMwMCIgaGVpZ2h0PSIxNTAiPjxjaXJjbGUgcj0iMS41IiBjeD0iNTAiIGN5PSIzMCIgZmlsbD0iYmxhY2siPjwvY2lyY2xlPjxjaXJjbGUgcj0iMS41IiBjeD0iMjQwIiBjeT0iMzAiIGZpbGw9ImJsYWNrIj48L2NpcmNsZT48Y2lyY2xlIHI9IjEuNSIgY3g9IjE1MCIgY3k9IjEyMCIgZmlsbD0iYmxhY2siPjwvY2lyY2xlPjwvc3ZnPg=="`;
30 changes: 30 additions & 0 deletions tests/signature_pad.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,47 @@ describe('user interactions', () => {
clientX: 50,
clientY: 30,
pressure: 1,
buttons: 1,
}),
);
document.dispatchEvent(
new PointerEvent('pointerup', {
clientX: 50,
clientY: 30,
pressure: 1,
buttons: 1,
}),
);
canvas.dispatchEvent(
new PointerEvent('pointerdown', {
clientX: 240,
clientY: 30,
pressure: 1,
buttons: 1,
}),
);
document.dispatchEvent(
new PointerEvent('pointerup', {
clientX: 240,
clientY: 30,
pressure: 1,
buttons: 1,
}),
);
canvas.dispatchEvent(
new PointerEvent('pointerdown', {
clientX: 150,
clientY: 120,
pressure: 1,
buttons: 1,
}),
);
document.dispatchEvent(
new PointerEvent('pointerup', {
clientX: 150,
clientY: 120,
pressure: 1,
buttons: 1,
}),
);
expect(pad.toDataURL('image/svg+xml')).toMatchSnapshot();
Expand Down Expand Up @@ -519,20 +546,23 @@ describe('Signature events.', () => {
clientX: 50,
clientY: 30,
pressure: 1,
buttons: 1,
}),
);
canvas.dispatchEvent(
new PointerEvent('pointermove', {
clientX: 50,
clientY: 40,
pressure: 1,
buttons: 1,
}),
);
document.dispatchEvent(
new PointerEvent('pointerup', {
clientX: 50,
clientY: 40,
pressure: 1,
buttons: 0,
}),
);

Expand Down
Loading

0 comments on commit 5af7098

Please sign in to comment.