本文整理汇总了TypeScript中test/TestSupport.delay_for函数的典型用法代码示例。如果您正苦于以下问题:TypeScript delay_for函数的具体用法?TypeScript delay_for怎么用?TypeScript delay_for使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delay_for函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should not make request if cached', () => {
const onLoad = spy();
const onChange = spy();
const resource = new Resource(schema.users, new RefraxOptions());
let fragment: FragmentResult;
resource.on('load', onLoad);
resource.on('change', onChange);
return delay_for_resource_request(resource)()
.then(() => {
expect(onLoad.callCount).to.equal(1);
expect(onChange.callCount).to.equal(1);
expect(mock_request_count()).to.equal(1);
expect(resource.data).to.deep.equal(dataCollectionUsers);
expect(resource.status).to.equal(IStatus.complete);
expect(resource.timestamp).to.not.equal(ITimestamp.loading);
fragment = resource._fetchFragment();
})
.then(delay_for())
.then(() => {
expect(fragment).is.instanceof(FragmentResult);
expect(fragment.data).to.deep.equal(dataCollectionUsers);
expect(fragment.status).to.equal(IStatus.complete);
expect(fragment.timestamp).to.not.equal(ITimestamp.loading);
expect(resource.data).to.deep.equal(dataCollectionUsers);
expect(resource.status).to.equal(IStatus.complete);
expect(resource.timestamp).to.not.equal(ITimestamp.loading);
expect(mock_request_count()).to.equal(1);
expect(onLoad.callCount).to.equal(1);
expect(onChange.callCount).to.equal(1);
});
});
示例2: mock_get
.then(() => {
mock_get('/users', dataCollectionUsers);
expect(mock_request_count()).to.equal(0);
// re-enable fetch get
resource._options.noFetchGet = false;
const result = resource._fetchFragment({ noFetchGet: true });
expect(result).is.instanceof(FragmentResult);
return delay_for()()
.then(() => {
expect(mock_request_count()).to.equal(0);
});
});