Skip to content

Commit

Permalink
test: fix failed unit
Browse files Browse the repository at this point in the history
  • Loading branch information
hughfenghen committed Dec 23, 2024
1 parent c6e4ebb commit ee8a9f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 46 deletions.
54 changes: 9 additions & 45 deletions packages/av-canvas/src/__tests__/__snapshots__/utils.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,14 @@

exports[`ctrls 1`] = `
{
"b": Le {
"fixedAspectRatio": false,
"fixedScaleCenter": false,
"on": [Function],
},
"l": Le {
"fixedAspectRatio": false,
"fixedScaleCenter": false,
"on": [Function],
},
"lb": Le {
"fixedAspectRatio": false,
"fixedScaleCenter": false,
"on": [Function],
},
"lt": Le {
"fixedAspectRatio": false,
"fixedScaleCenter": false,
"on": [Function],
},
"r": Le {
"fixedAspectRatio": false,
"fixedScaleCenter": false,
"on": [Function],
},
"rb": Le {
"fixedAspectRatio": false,
"fixedScaleCenter": false,
"on": [Function],
},
"rotate": Le {
"fixedAspectRatio": false,
"fixedScaleCenter": false,
"on": [Function],
},
"rt": Le {
"fixedAspectRatio": false,
"fixedScaleCenter": false,
"on": [Function],
},
"t": Le {
"fixedAspectRatio": false,
"fixedScaleCenter": false,
"on": [Function],
},
"b": "{x: -8, y: 42, w: 16, h: 16}",
"l": "{x: -58, y: -8, w: 16, h: 16}",
"lb": "{x: -58, y: 42, w: 16, h: 16}",
"lt": "{x: -58, y: -58, w: 16, h: 16}",
"r": "{x: 42, y: -8, w: 16, h: 16}",
"rb": "{x: 42, y: 42, w: 16, h: 16}",
"rotate": "{x: -12, y: -94, w: 24, h: 24}",
"rt": "{x: 42, y: -58, w: 16, h: 16}",
"t": "{x: -8, y: -58, w: 16, h: 16}",
}
`;
11 changes: 10 additions & 1 deletion packages/av-canvas/src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ afterAll(() => {
test('ctrls', () => {
const rect = new Rect(0, 0, 100, 100);

expect(rectCtrlsGetter(rect)).toMatchSnapshot();
const ctrls = rectCtrlsGetter(rect);
expect(
Object.fromEntries(
Object.entries(ctrls).map(([key, ctrl]) => [key, stringifyRect(ctrl)]),
),
).toMatchSnapshot();
});

// 固定比例后,ctrls 将移除 t,b,l,r 控制点
Expand All @@ -42,3 +47,7 @@ test('fixedAspectRatio', () => {
'rotate',
]);
});

function stringifyRect(rect: Rect) {
return `{x: ${rect.x}, y: ${rect.y}, w: ${rect.w}, h: ${rect.h}}`;
}

0 comments on commit ee8a9f3

Please sign in to comment.