本文整理匯總了TypeScript中@dojo/framework/testing/harness.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: stub
it('should call pageChange with first page at scroll 0', () => {
const pageChangeStub = stub();
const page: any[] = [];
for (let i = 0; i < 100; i++) {
const item = { id: 'id' };
page.push(item);
}
const h = harness(() =>
w(Body, {
totalRows: 1000,
pageSize: 100,
height: 400,
pages: {
'page-1': page
},
columnConfig: [] as any,
fetcher: noop,
updater: noop,
pageChange: pageChangeStub,
onScroll: noop
})
);
h.trigger('@root', 'onscroll', {
target: {
scrollTop: 0,
scrollLeft: 0
}
});
h.expect(() => h.getRender());
assert.isTrue(pageChangeStub.calledWith(1));
});
示例2: harness
it('should render with a control div and only one widget if small', () => {
resizeGetStub = () => ({ isSmall: true, isMedium: false });
const h = harness(() => w(TestWidget, {}));
h.expect(() =>
v('div', { classes: css.root }, [
v('div', { key: 'controls', classes: css.controls }, [
w(Button, {
onClick: () => {
}
}, [
'Switch Demo Positions'
])
]),
v('div', { key: 'root' }, [
v('div', { classes: css.parentContainer }, [
w(ResizableSection, {
key: 0,
isSmall: true,
isMedium: false,
expand: () => {
},
shrink: () => {
},
columns: 2
}, [ w(Article, {}) ])
])
])
])
);
})
示例3: Promise
it('should request data when the bottom is visible', () => {
const loadStub = () => {
return Promise.resolve([v('div', {}, ['test'])]);
};
intersectionGetStub = () => {
return {
isIntersecting: true
};
};
const h = harness(() => w(TestWidget, {
onRequestItems: loadStub
}));
h.expect(() =>
v('div', {}, [
v('div', { key: 'bottom', classes: css.bottom })
])
);
return new Promise(resolve => {
setTimeout(() => {
h.expect(() =>
v('div', {}, [
v('div', {}, ['test']),
v('div', { key: 'bottom', classes: css.bottom })
])
);
resolve();
}, 10);
});
});
示例4: harness
it('accepts decimal values', () => {
const h = harness(() => w(Progress, {
max: 1,
value: 0.2
}));
h.expect(() => expectedVDom({ width: 20, output: '20%', value: 0.2, max: 1 }));
});
示例5: harness
it('should render the grid when the dimension are known', () => {
const h = harness(() =>
w(MockMetaMixin(Grid, mockMeta), {
fetcher: noop,
updater: noop,
columnConfig,
height: 250
})
);
h.expect(() =>
v('div', { key: 'root', classes: [css.root, fixedCss.rootFixed], role: 'table', 'aria-rowcount': null }, [
v('div', {
key: 'header',
scrollLeft: 0,
classes: [css.header, fixedCss.headerFixed, null],
row: 'rowgroup'
}, [
w(Header, {
key: 'header-row',
columnConfig,
sorter: noop,
sort: undefined,
filter: undefined,
filterer: noop,
classes: undefined,
theme: undefined,
filterRenderer: undefined,
sortRenderer: undefined
})
]),
w(Body, {
key: 'body',
pages: {},
totalRows: undefined,
pageSize: 100,
columnConfig,
pageChange: noop,
updater: noop,
fetcher: noop,
onScroll: noop,
height: 50,
classes: undefined,
theme: undefined
}),
v('div', { key: 'footer' }, [
w(Footer, {
key: 'footer-row',
total: undefined,
page: 1,
pageSize: 100,
classes: undefined,
theme: undefined
})
])
])
);
});