本文整理汇总了TypeScript中models/shared/usage_data_reporter.UsageDataReporter.report方法的典型用法代码示例。如果您正苦于以下问题:TypeScript UsageDataReporter.report方法的具体用法?TypeScript UsageDataReporter.report怎么用?TypeScript UsageDataReporter.report使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models/shared/usage_data_reporter.UsageDataReporter
的用法示例。
在下文中一共展示了UsageDataReporter.report方法的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);
}
});