aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js
diff options
context:
space:
mode:
authorMatthew Shao <me@matshao.com>2017-05-15 16:44:02 +0800
committerMatthew Shao <me@matshao.com>2017-05-15 16:44:02 +0800
commit6757eda23a8a927d8ad2228fe64e300298d5d57e (patch)
treebf69db468854a985fd9080ff8b5a91e34ad332ff /web/src/js
parent801f78f3ed68ba53364383e2bc8cc2ffa3b2f24d (diff)
downloadmitmproxy-6757eda23a8a927d8ad2228fe64e300298d5d57e.tar.gz
mitmproxy-6757eda23a8a927d8ad2228fe64e300298d5d57e.tar.bz2
mitmproxy-6757eda23a8a927d8ad2228fe64e300298d5d57e.zip
[web] Add tests for js/components/helpers/VirtualScroll.js
Diffstat (limited to 'web/src/js')
-rw-r--r--web/src/js/__tests__/components/helpers/VirtualScrollSpec.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/web/src/js/__tests__/components/helpers/VirtualScrollSpec.js b/web/src/js/__tests__/components/helpers/VirtualScrollSpec.js
new file mode 100644
index 00000000..8081e90d
--- /dev/null
+++ b/web/src/js/__tests__/components/helpers/VirtualScrollSpec.js
@@ -0,0 +1,21 @@
+import { calcVScroll } from '../../../components/helpers/VirtualScroll'
+
+describe('VirtualScroll', () => {
+
+ it('should return default state without options', () => {
+ expect(calcVScroll()).toEqual({start: 0, end: 0, paddingTop: 0, paddingBottom: 0})
+ })
+
+ it('should calculate position without itemHeights', () => {
+ expect(calcVScroll({itemCount: 0, rowHeight: 32, viewportHeight: 400, viewportTop: 0})).toEqual({
+ start: 0, end: 0, paddingTop: 0, paddingBottom: 0
+ })
+ })
+
+ it('should calculate position with itemHeights', () => {
+ expect(calcVScroll({itemCount: 5, itemHeights: [100, 100, 100, 100, 100],
+ viewportHeight: 300, viewportTop: 0})).toEqual({
+ start: 0, end: 4, paddingTop: 0, paddingBottom: 100
+ })
+ })
+})