This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
ef1d5b5
commit 1dcc05a
Showing
6 changed files
with
50 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ webpack.config.js | |
.prettierignore | ||
.prettierrc | ||
tslint.json | ||
cypress |
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,13 @@ | ||
import * as ScrollUtility from "../" | ||
|
||
function takeScreenShot(delay: number = 0) { | ||
cy.wait(delay).then(() => cy.screenshot("basic", { capture: "viewport" })) | ||
} | ||
|
||
function withWindow<T = void>(f: (window: Window & { ScrollUtility: typeof ScrollUtility }) => T) { | ||
cy.window().then(wind => { | ||
f(wind as Window & { ScrollUtility: typeof ScrollUtility }) | ||
}) | ||
} | ||
|
||
export { withWindow, takeScreenShot } |
Binary file not shown.
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,22 @@ | ||
import { withWindow } from "../common" | ||
|
||
context("Basic", () => { | ||
beforeEach(() => { | ||
cy.visit("http://localhost:8080") | ||
}) | ||
it("should have ScrollUtility defined", () => { | ||
cy.window().should("have.property", "ScrollUtility") | ||
}) | ||
it("should scroll", () => { | ||
withWindow(window => { | ||
const scrollManager = new window.ScrollUtility.Scroll() | ||
const element = window.document.querySelector("#scrollable") | ||
scrollManager.scrollBy(scrollManager.misc.getDistToElement(element!), 1000) | ||
scrollManager.scrollBy(scrollManager.misc.getDistToElement(element!), 1000, true) | ||
window.setTimeout(() => { | ||
scrollManager.scrollBy(scrollManager.misc.getDistToElement(element!), 0) | ||
scrollManager.scrollBy(scrollManager.misc.getDistToElement(element!, 0, true), 0, true) | ||
}, 1000) | ||
}) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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,14 @@ | ||
import { withWindow } from "../common" | ||
|
||
context("Misc", () => { | ||
before(() => { | ||
cy.visit("http://localhost:8080") | ||
}) | ||
beforeEach(() => { | ||
withWindow(window => { | ||
const windowScrollManager = window.ScrollUtility.default | ||
windowScrollManager.misc.scrollTo(0, 0, false) | ||
windowScrollManager.misc.scrollTo(0, 0, true) | ||
}) | ||
}) | ||
}) |