-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into update-js-packages
- Loading branch information
Showing
7 changed files
with
320 additions
and
44 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 |
---|---|---|
@@ -1,39 +1,41 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>JqTree devserver</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<meta | ||
name="description" | ||
content="JqTree is a jQuery widget for displaying a tree structure in html" | ||
/> | ||
<link rel="stylesheet" href="/jqtree.css" /> | ||
<style> | ||
body { | ||
font-size: 20px; | ||
} | ||
ul.jqtree-tree ul.jqtree_common { | ||
margin-left: 128px; | ||
} | ||
#scroll-container { | ||
height: 200px; | ||
width: 400px; | ||
overflow-y: scroll; | ||
user-select: none; | ||
background-color: #eee; | ||
margin: 128px; | ||
padding: 8px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="scroll-container"> | ||
<div id="tree1"></div> | ||
</div> | ||
</body> | ||
<script src="/bower_components/jquery/dist/jquery.min.js"></script> | ||
<script src="/tree.jquery.js"></script> | ||
<script src="/example_data.js"></script> | ||
<script src="/devserver_scroll.js"></script> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<title>JqTree devserver</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<meta name="description" content="JqTree is a jQuery widget for displaying a tree structure in html" /> | ||
<link rel="stylesheet" href="/jqtree.css" /> | ||
<style> | ||
body { | ||
font-size: 20px; | ||
} | ||
|
||
ul.jqtree-tree ul.jqtree_common { | ||
margin-left: 128px; | ||
} | ||
|
||
#scroll-container { | ||
height: 200px; | ||
width: 400px; | ||
overflow-y: scroll; | ||
user-select: none; | ||
background-color: #eee; | ||
margin: 128px; | ||
padding: 8px; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="scroll-container"> | ||
<div id="tree1"></div> | ||
</div> | ||
</body> | ||
<script src="/vendor/jquery.min.js"></script> | ||
<script src="/tree.jquery.js"></script> | ||
<script src="/example_data.js"></script> | ||
<script src="/devserver_scroll.js"></script> | ||
|
||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
import { mockElementBoundingClientRect } from "jsdom-testing-mocks"; | ||
|
||
import ContainerScrollParent from "../../scrollHandler/containerScrollParent"; | ||
|
||
afterEach(() => { | ||
jest.useRealTimers(); | ||
}); | ||
|
||
describe("checkHorizontalScrolling", () => { | ||
it("scrolls to the left when pageX is near the left edge", () => { | ||
jest.useFakeTimers(); | ||
|
||
const refreshHitAreas = jest.fn(); | ||
const container = document.createElement("div"); | ||
|
||
const scrollBy = jest.fn(); | ||
container.scrollBy = scrollBy; | ||
|
||
mockElementBoundingClientRect(container, { | ||
height: 100, | ||
width: 100, | ||
x: 10, | ||
y: 10, | ||
}); | ||
|
||
const containerScrollParent = new ContainerScrollParent({ | ||
container, | ||
refreshHitAreas, | ||
}); | ||
|
||
containerScrollParent.checkHorizontalScrolling(20); | ||
|
||
expect(scrollBy).not.toHaveBeenCalled(); | ||
jest.advanceTimersByTime(50); | ||
expect(scrollBy).toHaveBeenCalledWith({ | ||
behavior: "instant", | ||
left: -20, | ||
top: 0, | ||
}); | ||
}); | ||
|
||
it("stops scrolling when pageX is moved from the left edge", () => { | ||
jest.useFakeTimers(); | ||
|
||
const refreshHitAreas = jest.fn(); | ||
const container = document.createElement("div"); | ||
|
||
const scrollBy = jest.fn(); | ||
container.scrollBy = scrollBy; | ||
|
||
mockElementBoundingClientRect(container, { | ||
height: 100, | ||
width: 100, | ||
x: 10, | ||
y: 10, | ||
}); | ||
|
||
const containerScrollParent = new ContainerScrollParent({ | ||
container, | ||
refreshHitAreas, | ||
}); | ||
|
||
containerScrollParent.checkHorizontalScrolling(20); | ||
|
||
expect(scrollBy).not.toHaveBeenCalled(); | ||
jest.advanceTimersByTime(50); | ||
expect(scrollBy).toHaveBeenCalledWith({ | ||
behavior: "instant", | ||
left: -20, | ||
top: 0, | ||
}); | ||
|
||
containerScrollParent.checkHorizontalScrolling(50); | ||
jest.advanceTimersByTime(50); | ||
|
||
expect(scrollBy).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
|
||
describe("checkVerticalScrolling", () => { | ||
it("scrolls to the top when pageY is near the top edge", () => { | ||
jest.useFakeTimers(); | ||
|
||
const refreshHitAreas = jest.fn(); | ||
const container = document.createElement("div"); | ||
|
||
const scrollBy = jest.fn(); | ||
container.scrollBy = scrollBy; | ||
|
||
mockElementBoundingClientRect(container, { | ||
height: 100, | ||
width: 100, | ||
x: 10, | ||
y: 10, | ||
}); | ||
|
||
const containerScrollParent = new ContainerScrollParent({ | ||
container, | ||
refreshHitAreas, | ||
}); | ||
|
||
containerScrollParent.checkVerticalScrolling(9); | ||
|
||
expect(scrollBy).not.toHaveBeenCalled(); | ||
jest.advanceTimersByTime(50); | ||
expect(scrollBy).toHaveBeenCalledWith({ | ||
behavior: "instant", | ||
left: 0, | ||
top: -20, | ||
}); | ||
}); | ||
|
||
it("stops scrolling when pageX is moved from the left edge", () => { | ||
jest.useFakeTimers(); | ||
|
||
const refreshHitAreas = jest.fn(); | ||
const container = document.createElement("div"); | ||
|
||
const scrollBy = jest.fn(); | ||
container.scrollBy = scrollBy; | ||
|
||
mockElementBoundingClientRect(container, { | ||
height: 100, | ||
width: 100, | ||
x: 10, | ||
y: 10, | ||
}); | ||
|
||
const containerScrollParent = new ContainerScrollParent({ | ||
container, | ||
refreshHitAreas, | ||
}); | ||
|
||
containerScrollParent.checkVerticalScrolling(9); | ||
|
||
expect(scrollBy).not.toHaveBeenCalled(); | ||
jest.advanceTimersByTime(50); | ||
expect(scrollBy).toHaveBeenCalledWith({ | ||
behavior: "instant", | ||
left: 0, | ||
top: -20, | ||
}); | ||
|
||
containerScrollParent.checkVerticalScrolling(50); | ||
jest.advanceTimersByTime(50); | ||
|
||
expect(scrollBy).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
Oops, something went wrong.