mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
[web] Add tests for js/components/helpers/VirtualScroll.js
This commit is contained in:
parent
801f78f3ed
commit
6757eda23a
21
web/src/js/__tests__/components/helpers/VirtualScrollSpec.js
Normal file
21
web/src/js/__tests__/components/helpers/VirtualScrollSpec.js
Normal file
@ -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
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user