本文整理汇总了TypeScript中models/shared/usage_data_reporter.UsageDataReporter类的典型用法代码示例。如果您正苦于以下问题:TypeScript UsageDataReporter类的具体用法?TypeScript UsageDataReporter怎么用?TypeScript UsageDataReporter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UsageDataReporter类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should not update last reported time if reporting to remote server fails', async () => {
const yesterday = lastReportedYesterday();
mockDataSharingReportingGetAPIAndReturn(allowedReportingJSON);
mockDataSharingReportingStartAPI();
mockDataSharingServerGetEncryptionKeysAndReturn('some-signature', 'valid-public-key');
mockUsageDataAPIAndReturn(encryptedUsageData);
mockDataSharingServerAPIAndFail();
expect(localStorage.getItem(USAGE_DATA_LAST_REPORTED_TIME_KEY)).toBe(`${yesterday}`);
try {
await UsageDataReporter.report();
} catch (e) {
expect(jasmine.Ajax.requests.count()).toBe(5);
expect(jasmine.Ajax.requests.at(0).url).toBe(usageReportingGetURL);
expect(jasmine.Ajax.requests.at(1).url).toBe(usageReportingStartURL);
expect(jasmine.Ajax.requests.at(1).method).toBe('POST');
expect(jasmine.Ajax.requests.at(2).url).toBe(allowedReportingJSON._embedded.data_sharing_get_encryption_keys_url);
expect(jasmine.Ajax.requests.at(3).url).toBe(encryptedUsageDataURL);
expect(jasmine.Ajax.requests.at(3).method).toBe('POST');
expect(jasmine.Ajax.requests.at(4).url).toBe(allowedReportingJSON._embedded.data_sharing_server_url);
expect(jasmine.Ajax.requests.at(4).method).toBe('POST');
expect(jasmine.Ajax.requests.filter(usageReportingCompleteURL)).toHaveLength(0);
// verify that the last reported time is updated in the local storage
expect(new Date(+(localStorage.getItem(USAGE_DATA_LAST_REPORTED_TIME_KEY) || '')).getDate()).toBe(new Date().getDate());
expect(new Date(+(localStorage.getItem(USAGE_DATA_LAST_REPORTED_TIME_KEY) || '')).getTime()).toBeGreaterThan(yesterday);
}
});
开发者ID:GaneshSPatil,项目名称:gocd,代码行数:34,代码来源:usage_data_reporter_spec.ts
注:本文中的models/shared/usage_data_reporter.UsageDataReporter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论