Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'refresh',
'enable',
'disable',
'destroy',
// scroller
'beforeScrollStart',
'scrollStart',
'scroll',
'scrollEnd',
'touchEnd',
'flick'
])
const res = {
wrapper: wrapper,
options: options,
hooks: new EventEmitter([
'init',
'refresh',
'enable',
'disable',
'destroy'
]),
scroller: new Scroller(wrapper, options),
// own methods
proxy: jest.fn(),
refresh: jest.fn(),
// proxy methods
scrollTo: jest.fn(),
resetPosition: jest.fn(),
registerType: jest.fn().mockImplementation((names: string[]) => {
names.forEach(name => {
const eventTypes = eventEmitter.eventTypes
it('bubbling', () => {
const parentHooks = new EventEmitter(['test'])
const childHooks = new EventEmitter(['test'])
bubbling(childHooks, parentHooks, ['test'])
const handler = jest.fn(() => {})
parentHooks.on('test', handler)
childHooks.trigger('test', 'dummy test')
expect(handler).toBeCalledWith('dummy test')
})
})
it('bubbling', () => {
const parentHooks = new EventEmitter(['test'])
const childHooks = new EventEmitter(['test'])
bubbling(childHooks, parentHooks, ['test'])
const handler = jest.fn(() => {})
parentHooks.on('test', handler)
childHooks.trigger('test', 'dummy test')
expect(handler).toBeCalledWith('dummy test')
})
})
beforeAll(() => {
hooks = new EventEmitter([
'beforeStart',
'scroll',
'refresh',
'momentum',
'scrollEnd',
'forceStop',
'flick',
'destroy'
])
})
beforeAll(() => {
hooks = new EventEmitter([
'start',
'beforeMove',
'beforeEnd',
'beforeTranslate',
'destroy',
'zoomStart',
'zoomEnd',
'ignoreDisMoveForSamePos'
])
})
.mockImplementation((wrapper, bscrollOptions) => {
return {
wrapper,
options: bscrollOptions,
initiated: 1,
pointX: 0,
pointY: 0,
startClickRegister: new EventRegister(wrapper, []),
moveEndRegister: new EventRegister(wrapper, []),
hooks: new EventEmitter(['beforeStart', 'start', 'move', 'end', 'click']),
destroy: jest.fn()
}
})
const actions = new Actions(
scrollBehaviorX,
scrollBehaviorY,
actionsHandler,
animater,
bscrollOptions
)
return {
wrapper,
content,
options: bscrollOptions,
translater,
animater,
actionsHandler,
actions,
hooks: new EventEmitter([
'beforeStart',
'beforeMove',
'beforeScrollStart',
'scrollStart',
'scroll',
'beforeEnd',
'scrollEnd',
'refresh',
'touchEnd',
'end',
'flick',
'scrollCancel',
'momentum',
'scrollTo',
'scrollToElement',
'transitionEnd',
const Behavior = jest.fn().mockImplementation((content, bscrollOptions) => {
return {
content,
options: bscrollOptions,
startPos: 0,
absStartPos: 0,
dist: 0,
minScrollPos: 0,
maxScrollPos: 0,
hasScroll: true,
direction: 0,
movingDirection: 0,
relativeOffset: 0,
wrapperSize: 0,
contentSize: 0,
hooks: new EventEmitter(['momentum', 'end']),
start: jest.fn(),
move: jest.fn(),
end: jest.fn(),
updateDirection: jest.fn(),
refresh: jest.fn(),
updatePosition: jest.fn(),
getCurrentPos: jest.fn(),
checkInBoundary: jest.fn(),
adjustPosition: jest.fn(),
updateStartPos: jest.fn(),
updateAbsStartPos: jest.fn(),
resetStartPos: jest.fn(),
getAbsDist: jest.fn(),
destroy: jest.fn()
}
})
) {
this.bscroll = indicator.bscroll
this.startEventRegister = new EventRegister(this.indicator.el, [
{
name: options.disableMouse ? 'touchstart' : 'mousedown',
handler: this._start.bind(this)
}
])
this.endEventRegister = new EventRegister(window, [
{
name: options.disableMouse ? 'touchend' : 'mouseup',
handler: this._end.bind(this)
}
])
this.hooks = new EventEmitter(['touchStart', 'touchMove', 'touchEnd'])
}
const EventHandler = jest.fn().mockImplementation(() => {
return {
hooks: new EventEmitter(['touchStart', 'touchMove', 'touchEnd'])
}
})