From d72f44556d9589111430d9934445048744c342fe Mon Sep 17 00:00:00 2001 From: Andrew Seguin Date: Thu, 15 Mar 2018 10:31:46 -0700 Subject: [PATCH] feat(elements): rebase (#22413) PR Close #22413 --- .../announcement-bar.component.spec.ts | 10 ++++++++-- .../announcement-bar/announcement-bar.component.ts | 4 ++-- .../app/custom-elements/code/pretty-printer.service.ts | 4 ++-- .../app/layout/doc-viewer/doc-viewer.component.spec.ts | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/aio/src/app/custom-elements/announcement-bar/announcement-bar.component.spec.ts b/aio/src/app/custom-elements/announcement-bar/announcement-bar.component.spec.ts index 009c720c15..068f792ad3 100644 --- a/aio/src/app/custom-elements/announcement-bar/announcement-bar.component.spec.ts +++ b/aio/src/app/custom-elements/announcement-bar/announcement-bar.component.spec.ts @@ -66,7 +66,10 @@ describe('AnnouncementBarComponent', () => { const request = httpMock.expectOne('generated/announcements.json'); request.flush('some random response'); 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`', () => { @@ -74,7 +77,10 @@ describe('AnnouncementBarComponent', () => { const request = httpMock.expectOne('generated/announcements.json'); request.error(new ErrorEvent('404')); 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:/); }); }); diff --git a/aio/src/app/custom-elements/announcement-bar/announcement-bar.component.ts b/aio/src/app/custom-elements/announcement-bar/announcement-bar.component.ts index ebe511873f..abd88d0b2d 100644 --- a/aio/src/app/custom-elements/announcement-bar/announcement-bar.component.ts +++ b/aio/src/app/custom-elements/announcement-bar/announcement-bar.component.ts @@ -59,12 +59,12 @@ export class AnnouncementBarComponent implements OnInit { ngOnInit() { this.http.get(announcementsPath) .catch(error => { - this.logger.error(`${announcementsPath} request failed: ${error.message}`); + this.logger.error(new Error(`${announcementsPath} request failed: ${error.message}`)); return []; }) .map(announcements => this.findCurrentAnnouncement(announcements)) .catch(error => { - this.logger.error(`${announcementsPath} contains invalid data: ${error.message}`); + this.logger.error(new Error(`${announcementsPath} contains invalid data: ${error.message}`)); return []; }) .subscribe(announcement => this.announcement = announcement); diff --git a/aio/src/app/custom-elements/code/pretty-printer.service.ts b/aio/src/app/custom-elements/code/pretty-printer.service.ts index 28131046c9..cdfed57360 100644 --- a/aio/src/app/custom-elements/code/pretty-printer.service.ts +++ b/aio/src/app/custom-elements/code/pretty-printer.service.ts @@ -33,8 +33,8 @@ export class PrettyPrinter { .then( () => (window as any)['prettyPrintOne'], err => { - const msg = 'Cannot get prettify.js from server'; - this.logger.error(msg, err); + const msg = `Cannot get prettify.js from server: ${err.message}`; + this.logger.error(new Error(msg)); // return a pretty print fn that always fails. return () => { throw new Error(msg); }; }); diff --git a/aio/src/app/layout/doc-viewer/doc-viewer.component.spec.ts b/aio/src/app/layout/doc-viewer/doc-viewer.component.spec.ts index 967ac8b926..8e4f9839c5 100644 --- a/aio/src/app/layout/doc-viewer/doc-viewer.component.spec.ts +++ b/aio/src/app/layout/doc-viewer/doc-viewer.component.spec.ts @@ -496,7 +496,7 @@ describe('DocViewerComponent', () => { expect(swapViewsSpy).not.toHaveBeenCalled(); expect(docViewer.nextViewContainer.innerHTML).toBe(''); 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: 'robots', content: 'noindex' });