summaryrefslogtreecommitdiffstats
path: root/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_test.html
diff options
context:
space:
mode:
Diffstat (limited to 'polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_test.html')
-rw-r--r--polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_test.html39
1 files changed, 27 insertions, 12 deletions
diff --git a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_test.html b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_test.html
index 5a4b8ba9d2..adbe6181d3 100644
--- a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_test.html
+++ b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager_test.html
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<!--
+@license
Copyright (C) 2016 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
@@ -222,17 +223,13 @@ limitations under the License.
});
test('Called when top and bottom not visible', () => {
- sandbox.stub(element, '_targetIsVisible', () => {
- return false;
- });
+ sandbox.stub(element, '_targetIsVisible').returns(false);
element._scrollToTarget();
assert.isTrue(scrollStub.called);
});
test('Not called when top and bottom visible', () => {
- sandbox.stub(element, '_targetIsVisible', () => {
- return true;
- });
+ sandbox.stub(element, '_targetIsVisible').returns(true);
element._scrollToTarget();
assert.isFalse(scrollStub.called);
});
@@ -240,26 +237,44 @@ limitations under the License.
test('Called when top is visible, bottom is not, scroll is lower', () => {
const visibleStub = sandbox.stub(element, '_targetIsVisible',
() => visibleStub.callCount === 2);
- window.scrollY = 15;
- sandbox.stub(element, '_calculateScrollToValue', () => {
- return 20;
+ sandbox.stub(element, '_getWindowDims').returns({
+ scrollX: 123,
+ scrollY: 15,
+ innerHeight: 1000,
+ pageYOffset: 0,
});
+ sandbox.stub(element, '_calculateScrollToValue').returns(20);
element._scrollToTarget();
assert.isTrue(scrollStub.called);
+ assert.isTrue(scrollStub.calledWithExactly(123, 20));
assert.equal(visibleStub.callCount, 2);
});
test('Called when top is visible, bottom not, scroll is higher', () => {
const visibleStub = sandbox.stub(element, '_targetIsVisible',
() => visibleStub.callCount === 2);
- window.scrollY = 25;
- sandbox.stub(element, '_calculateScrollToValue', () => {
- return 20;
+ sandbox.stub(element, '_getWindowDims').returns({
+ scrollX: 123,
+ scrollY: 25,
+ innerHeight: 1000,
+ pageYOffset: 0,
});
+ sandbox.stub(element, '_calculateScrollToValue').returns(20);
element._scrollToTarget();
assert.isFalse(scrollStub.called);
assert.equal(visibleStub.callCount, 2);
});
+
+ test('_calculateScrollToValue', () => {
+ sandbox.stub(element, '_getWindowDims').returns({
+ scrollX: 123,
+ scrollY: 25,
+ innerHeight: 300,
+ pageYOffset: 0,
+ });
+ assert.equal(element._calculateScrollToValue(1000, {offsetHeight: 10}),
+ 905);
+ });
});
});
</script>