-
-
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.
- Loading branch information
Showing
10 changed files
with
187 additions
and
50 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
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,39 @@ | ||
import { waitFor } from "@testing-library/react"; | ||
|
||
import { renderApp, sleep } from "../../utils"; | ||
|
||
describe("Pan Touch [Velocity]", () => { | ||
describe("When panning to coords", () => { | ||
it("should trigger velocity", async () => { | ||
const { content, touchPan, pinch } = renderApp(); | ||
pinch({ value: 1.5 }); | ||
expect(content.style.transform).toBe("translate(0px, 0px) scale(1.5)"); | ||
await sleep(10); | ||
touchPan({ x: 20, y: 20 }); | ||
expect(content.style.transform).toBe("translate(20px, 20px) scale(1.5)"); | ||
}); | ||
// it("should not trigger disabled velocity", async () => { | ||
// const { content, touchPan, pinch } = renderApp({ | ||
// disablePadding: false, | ||
// }); | ||
// pinch({ value: 1.2 }); | ||
// expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); | ||
// touchPan({ 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)"); | ||
// }); | ||
// }); | ||
// it("should accelerate to certain point", async () => { | ||
// const { content, touchPan, zoom } = renderApp(); | ||
// expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); | ||
// zoom({ value: 1.5 }); | ||
// expect(content.style.transform).toBe("translate(0px, 0px) scale(1.5)"); | ||
// touchPan({ x: 100, y: 100 }); | ||
// await sleep(10); | ||
// expect(content.style.transform).toBe( | ||
// "translate(100px, 100px) scale(1.5)", | ||
// ); | ||
// }); | ||
}); | ||
}); |
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,37 @@ | ||
import { renderApp } from "../../utils"; | ||
|
||
describe("Pinch [Callbacks]", () => { | ||
describe("When pinch zooming", () => { | ||
it("should trigger onPinch callbacks", async () => { | ||
const spy1 = jest.fn(); | ||
const spy2 = jest.fn(); | ||
const spy3 = jest.fn(); | ||
const { content, pinch } = renderApp({ | ||
onPinchStart: spy1, | ||
onPinch: spy2, | ||
onPinchStop: spy3, | ||
}); | ||
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); | ||
pinch({ value: 2 }); | ||
expect(spy1).toBeCalledTimes(1); | ||
expect(spy2).toBeCalled(); | ||
expect(spy3).toBeCalledTimes(1); | ||
}); | ||
|
||
it("should not trigger onZoom callbacks", async () => { | ||
const spy1 = jest.fn(); | ||
const spy2 = jest.fn(); | ||
const spy3 = jest.fn(); | ||
const { content, pinch } = renderApp({ | ||
onZoomStart: spy1, | ||
onZoom: spy2, | ||
onZoomStop: spy3, | ||
}); | ||
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); | ||
pinch({ value: 2 }); | ||
expect(spy1).toBeCalledTimes(0); | ||
expect(spy2).toBeCalledTimes(0); | ||
expect(spy3).toBeCalledTimes(0); | ||
}); | ||
}); | ||
}); |
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,40 @@ | ||
import { waitFor } from "@testing-library/dom"; | ||
import { renderApp } from "../../utils"; | ||
|
||
describe("Zoom [Callbacks]", () => { | ||
describe("When wheel zooming", () => { | ||
it("should trigger onZoom callbacks", async () => { | ||
const spy1 = jest.fn(); | ||
const spy2 = jest.fn(); | ||
const spy3 = jest.fn(); | ||
const { content, zoom } = renderApp({ | ||
onZoomStart: spy1, | ||
onZoom: spy2, | ||
onZoomStop: spy3, | ||
}); | ||
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); | ||
zoom({ value: 2 }); | ||
await waitFor(() => { | ||
expect(spy1).toBeCalledTimes(1); | ||
expect(spy2).toBeCalled(); | ||
expect(spy3).toBeCalledTimes(1); | ||
}); | ||
}); | ||
|
||
it("should not trigger onPinch callbacks", async () => { | ||
const spy1 = jest.fn(); | ||
const spy2 = jest.fn(); | ||
const spy3 = jest.fn(); | ||
const { content, zoom } = renderApp({ | ||
onPinchStart: spy1, | ||
onPinch: spy2, | ||
onPinchStop: spy3, | ||
}); | ||
expect(content.style.transform).toBe("translate(0px, 0px) scale(1)"); | ||
zoom({ value: 2 }); | ||
expect(spy1).toBeCalledTimes(0); | ||
expect(spy2).toBeCalledTimes(0); | ||
expect(spy3).toBeCalledTimes(0); | ||
}); | ||
}); | ||
}); |
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
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
Oops, something went wrong.