parent
0b45dfac29
commit
d72f44556d
|
@ -66,7 +66,10 @@ describe('AnnouncementBarComponent', () => {
|
||||||
const request = httpMock.expectOne('generated/announcements.json');
|
const request = httpMock.expectOne('generated/announcements.json');
|
||||||
request.flush('some random response');
|
request.flush('some random response');
|
||||||
expect(component.announcement).toBeUndefined();
|
expect(component.announcement).toBeUndefined();
|
||||||
expect(mockLogger.output.error[0][0]).toContain('generated/announcements.json contains invalid data:');
|
expect(mockLogger.output.error).toEqual([
|
||||||
|
[jasmine.any(Error)]
|
||||||
|
]);
|
||||||
|
expect(mockLogger.output.error[0][0].message).toMatch(/^generated\/announcements\.json contains invalid data:/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle a failed request for `announcements.json`', () => {
|
it('should handle a failed request for `announcements.json`', () => {
|
||||||
|
@ -74,7 +77,10 @@ describe('AnnouncementBarComponent', () => {
|
||||||
const request = httpMock.expectOne('generated/announcements.json');
|
const request = httpMock.expectOne('generated/announcements.json');
|
||||||
request.error(new ErrorEvent('404'));
|
request.error(new ErrorEvent('404'));
|
||||||
expect(component.announcement).toBeUndefined();
|
expect(component.announcement).toBeUndefined();
|
||||||
expect(mockLogger.output.error[0][0]).toContain('generated/announcements.json request failed:');
|
expect(mockLogger.output.error).toEqual([
|
||||||
|
[jasmine.any(Error)]
|
||||||
|
]);
|
||||||
|
expect(mockLogger.output.error[0][0].message).toMatch(/^generated\/announcements\.json request failed:/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -59,12 +59,12 @@ export class AnnouncementBarComponent implements OnInit {
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.http.get<Announcement[]>(announcementsPath)
|
this.http.get<Announcement[]>(announcementsPath)
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.logger.error(`${announcementsPath} request failed: ${error.message}`);
|
this.logger.error(new Error(`${announcementsPath} request failed: ${error.message}`));
|
||||||
return [];
|
return [];
|
||||||
})
|
})
|
||||||
.map(announcements => this.findCurrentAnnouncement(announcements))
|
.map(announcements => this.findCurrentAnnouncement(announcements))
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.logger.error(`${announcementsPath} contains invalid data: ${error.message}`);
|
this.logger.error(new Error(`${announcementsPath} contains invalid data: ${error.message}`));
|
||||||
return [];
|
return [];
|
||||||
})
|
})
|
||||||
.subscribe(announcement => this.announcement = announcement);
|
.subscribe(announcement => this.announcement = announcement);
|
||||||
|
|
|
@ -33,8 +33,8 @@ export class PrettyPrinter {
|
||||||
.then(
|
.then(
|
||||||
() => (window as any)['prettyPrintOne'],
|
() => (window as any)['prettyPrintOne'],
|
||||||
err => {
|
err => {
|
||||||
const msg = 'Cannot get prettify.js from server';
|
const msg = `Cannot get prettify.js from server: ${err.message}`;
|
||||||
this.logger.error(msg, err);
|
this.logger.error(new Error(msg));
|
||||||
// return a pretty print fn that always fails.
|
// return a pretty print fn that always fails.
|
||||||
return () => { throw new Error(msg); };
|
return () => { throw new Error(msg); };
|
||||||
});
|
});
|
||||||
|
|
|
@ -496,7 +496,7 @@ describe('DocViewerComponent', () => {
|
||||||
expect(swapViewsSpy).not.toHaveBeenCalled();
|
expect(swapViewsSpy).not.toHaveBeenCalled();
|
||||||
expect(docViewer.nextViewContainer.innerHTML).toBe('');
|
expect(docViewer.nextViewContainer.innerHTML).toBe('');
|
||||||
expect(logger.output.error).toEqual([
|
expect(logger.output.error).toEqual([
|
||||||
[`[DocViewer] Error preparing document 'bar': ${error.stack}`],
|
[jasmine.any(Error)]
|
||||||
]);
|
]);
|
||||||
expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'googlebot', content: 'noindex' });
|
expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'googlebot', content: 'noindex' });
|
||||||
expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'robots', content: 'noindex' });
|
expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'robots', content: 'noindex' });
|
||||||
|
|
Loading…
Reference in New Issue