-
-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: 💍 Added trackpad panning utils
- Loading branch information
Showing
5 changed files
with
166 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
__tests__/features/pan-track-pad/pan-track-pad.base.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { waitFor } from "@testing-library/react"; | ||
|
||
import { renderApp, sleep } from "../../utils"; | ||
|
||
describe("Pan TrackPad [Base]", () => { | ||
describe("When panning to coords", () => { | ||
it("should not change translate with disabled padding", async () => { | ||
const { content, trackPadPan } = renderApp({ | ||
wheel: { | ||
disabled: true, | ||
}, | ||
trackPadPanning: { | ||
disabled: false, | ||
}, | ||
disablePadding: true, | ||
}); | ||
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); | ||
trackPadPan({ x: -100, y: -100 }); | ||
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); | ||
}); | ||
it("should return to position with padding enabled", async () => { | ||
const { content, trackPadPan } = renderApp({ | ||
wheel: { | ||
disabled: true, | ||
}, | ||
trackPadPanning: { | ||
disabled: false, | ||
}, | ||
autoAlignment: { | ||
disabled: false, | ||
}, | ||
}); | ||
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); | ||
trackPadPan({ x: -100, y: -100 }); | ||
expect(content.style.transform).toBe( | ||
"translate(-100px, -100px) scale(1)", | ||
); | ||
await waitFor(() => { | ||
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); | ||
}); | ||
}); | ||
}); | ||
describe("When locked axis", () => { | ||
it("should not change x axis transform", async () => { | ||
const { content, trackPadPan } = renderApp({ | ||
wheel: { | ||
disabled: true, | ||
}, | ||
trackPadPanning: { | ||
disabled: false, | ||
lockAxisX: true, | ||
}, | ||
}); | ||
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); | ||
trackPadPan({ x: -100, y: -100 }); | ||
expect(content.style.transform).toBe("translate(0px, -100px) scale(1)"); | ||
}); | ||
it("should not change y axis transform", async () => { | ||
const { content, trackPadPan } = renderApp({ | ||
wheel: { | ||
disabled: true, | ||
}, | ||
trackPadPanning: { | ||
disabled: false, | ||
lockAxisY: true, | ||
}, | ||
}); | ||
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); | ||
trackPadPan({ x: -100, y: -100 }); | ||
expect(content.style.transform).toBe("translate(-100px, 0px) scale(1)"); | ||
}); | ||
}); | ||
describe("When disabled", () => { | ||
it("should not change transform", async () => { | ||
const { content, trackPadPan } = renderApp({ | ||
disabled: true, | ||
}); | ||
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); | ||
trackPadPan({ x: -100, y: -100 }); | ||
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters