Skip to content

Commit

Permalink
fix: pass threshold in test
Browse files Browse the repository at this point in the history
  • Loading branch information
fand committed Jul 23, 2024
1 parent c305973 commit 91d0d2e
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions packages/vfx-js/src/vfx-player.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe("isRectInViewport", () => {

test("no overflow", () => {
expect(
isRectInViewport(rect(0, 0, 1, 1), rect(0, 0, 1, 1), pad(0)),
isRectInViewport(rect(0, 0, 1, 1), rect(0, 0, 1, 1), pad(0), 0),
).toBe(true);

// adjacent rects
Expand All @@ -124,27 +124,31 @@ describe("isRectInViewport", () => {
rect(0, 0, 1, 1),
rect(-1, 0, 1, 1), // left
pad(0),
0,
),
).toBe(true);
expect(
isRectInViewport(
rect(0, 0, 1, 1),
rect(1, 0, 1, 1), // right
pad(0),
0,
),
).toBe(true);
expect(
isRectInViewport(
rect(0, 0, 1, 1),
rect(0, -1, 1, 1), // top
pad(0),
0,
),
).toBe(true);
expect(
isRectInViewport(
rect(0, 0, 1, 1),
rect(0, 1, 1, 1), // bottom
pad(0),
0,
),
).toBe(true);

Expand All @@ -154,34 +158,38 @@ describe("isRectInViewport", () => {
rect(0, 0, 1, 1),
rect(-2, 0, 1, 1), // 1px left
pad(0),
0,
),
).toBe(false);
expect(
isRectInViewport(
rect(0, 0, 1, 1),
rect(2, 0, 1, 1), // 1px right
pad(0),
0,
),
).toBe(false);
expect(
isRectInViewport(
rect(0, 0, 1, 1),
rect(0, -2, 1, 1), // 1px top
pad(0),
0,
),
).toBe(false);
expect(
isRectInViewport(
rect(0, 0, 1, 1),
rect(0, 2, 1, 1), // 1px bottom
pad(0),
0,
),
).toBe(false);
});

test("with overflow", () => {
expect(
isRectInViewport(rect(0, 0, 1, 1), rect(0, 0, 1, 1), pad(1)),
isRectInViewport(rect(0, 0, 1, 1), rect(0, 0, 1, 1), pad(1), 0),
).toBe(true);

// adjacent rects
Expand All @@ -190,27 +198,31 @@ describe("isRectInViewport", () => {
rect(0, 0, 1, 1),
rect(-1, 0, 1, 1), // left
pad(1),
0,
),
).toBe(true);
expect(
isRectInViewport(
rect(0, 0, 1, 1),
rect(1, 0, 1, 1), // right
pad(1),
0,
),
).toBe(true);
expect(
isRectInViewport(
rect(0, 0, 1, 1),
rect(0, -1, 1, 1), // top
pad(1),
0,
),
).toBe(true);
expect(
isRectInViewport(
rect(0, 0, 1, 1),
rect(0, 1, 1, 1), // bottom
pad(1),
0,
),
).toBe(true);

Expand All @@ -220,27 +232,31 @@ describe("isRectInViewport", () => {
rect(0, 0, 1, 1),
rect(-2, 0, 1, 1), // 1px left
pad(1),
0,
),
).toBe(true);
expect(
isRectInViewport(
rect(0, 0, 1, 1),
rect(2, 0, 1, 1), // 1px right
pad(1),
0,
),
).toBe(true);
expect(
isRectInViewport(
rect(0, 0, 1, 1),
rect(0, -2, 1, 1), // 1px top
pad(1),
0,
),
).toBe(true);
expect(
isRectInViewport(
rect(0, 0, 1, 1),
rect(0, 2, 1, 1), // 1px bottom
pad(1),
0,
),
).toBe(true);

Expand All @@ -250,27 +266,31 @@ describe("isRectInViewport", () => {
rect(0, 0, 1, 1),
rect(-3, 0, 1, 1), // 2px left
pad(1),
0,
),
).toBe(false);
expect(
isRectInViewport(
rect(0, 0, 1, 1),
rect(3, 0, 1, 1), // 2px right
pad(1),
0,
),
).toBe(false);
expect(
isRectInViewport(
rect(0, 0, 1, 1),
rect(0, -3, 1, 1), // 2px top
pad(1),
0,
),
).toBe(false);
expect(
isRectInViewport(
rect(0, 0, 1, 1),
rect(0, 3, 1, 1), // 2px bottom
pad(1),
0,
),
).toBe(false);
});
Expand Down

0 comments on commit 91d0d2e

Please sign in to comment.