mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
31 lines
727 B
JavaScript
31 lines
727 B
JavaScript
'use stric';
|
|
|
|
const test = require('tape');
|
|
const mockRequire = require('mock-require');
|
|
const stub = require('@cloudcmd/stub');
|
|
|
|
test('cloudcmd: client: polyfill: scrollIntoViewIfNeaded', (t) => {
|
|
const {DOM} = global;
|
|
const scroll = stub();
|
|
const el = {};
|
|
|
|
global.DOM = {};
|
|
|
|
mockRequire('scroll-into-view-if-needed', {
|
|
default: scroll
|
|
});
|
|
|
|
mockRequire.reRequire('./polyfill');
|
|
|
|
global.DOM.scrollIntoViewIfNeeded(el);
|
|
mockRequire.stop('scroll-into-view-if-neaded');
|
|
global.DOM = DOM;
|
|
|
|
const args = [
|
|
el, {
|
|
block: 'nearest',
|
|
}];
|
|
|
|
t.ok(scroll.calledWith(...args), 'should call scrollIntoViewIfNeaded');
|
|
t.end();
|
|
});
|