Skip to content

Commit

Permalink
test: fix padding offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Oct 22, 2023
1 parent 5f6d392 commit 995f6dc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
12 changes: 11 additions & 1 deletion packages/react-moveable/stories/1-Basic/0-Basic.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { expect } from "@storybook/jest";
import { add } from "../utils/story";
import { pan, pinch, rotate, wait } from "../utils/testing";
import { throttle } from "@daybrush/utils";
import { parseMat } from "css-to-mat";


export default {
Expand Down Expand Up @@ -158,7 +159,16 @@ export const BasicWarpable = add("Warpable", {
duration: 100,
interval: 10,
});
expect(target.style.transform).toBe(`matrix3d(1.04545, 0.0454545, 0, -0.000909091, 0.0454545, 1.04545, 0, -0.000909091, 0, 0, 1, 0, 0, 0, 0, 1)`);
const mat = parseMat(target.style.transform);

[
1.04545, 0.0454545, 0, -0.000909091,
0.0454545, 1.04545, 0, -0.000909091,
0, 0, 1, 0,
0, 0, 0, 1,
].forEach((v, i) => {
expect(mat[i]).toBeCloseTo(v, 4);
});
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export const OptionsPadding = add("padding", {
const widthLine = canvasElement.querySelector<HTMLElement>(`[data-line-key="render-line-0"]`)!;
const heightLine = canvasElement.querySelector<HTMLElement>(`[data-line-key="render-line-1"]`)!;

expect(Math.round(parseFloat(widthLine.style.width))).toBe(230);
expect(Math.round(parseFloat(heightLine.style.width))).toBe(220);
expect(Math.round(parseFloat(widthLine.style.width))).toBe(231);
expect(Math.round(parseFloat(heightLine.style.width))).toBe(221);

// left
expect(Math.round(paddingAreas[0].getBoundingClientRect().width)).toBe(10);
Expand Down
4 changes: 2 additions & 2 deletions packages/react-moveable/stories/99-Tests/Deafult.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ export const TestsTRSTarget = add("Test css translate & rotate & scale target",
const line2 = controlBox.querySelector<HTMLElement>(`[data-line-key="render-line-1"]`)!;

// 100x 200
expect(line1.style.width).toBe("100px");
expect(line2.style.width).toBe("200px");
expect(line1.style.width).toBe("101px");
expect(line2.style.width).toBe("201px");
expect(splitComma(splitBracket(controlBox.style.transform).value!).map(v => {
return parseInt(v, 10);
})).toEqual([243, 248, 0]);
Expand Down

0 comments on commit 995f6dc

Please sign in to comment.