From a3204f87fd6330d69186ffcbc13d95f5a05e5047 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Fri, 13 Apr 2018 14:48:44 +0300 Subject: [PATCH] test(aio): fix `DocViewerComponent` tests (#23359) Obsolete assertions left over from #23249. PR Close #23359 --- aio/e2e/app.e2e-spec.ts | 3 --- .../doc-viewer/doc-viewer.component.spec.ts | 16 ++++------------ 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/aio/e2e/app.e2e-spec.ts b/aio/e2e/app.e2e-spec.ts index 0f0fa2aefd..dba15ab86d 100644 --- a/aio/e2e/app.e2e-spec.ts +++ b/aio/e2e/app.e2e-spec.ts @@ -162,15 +162,12 @@ describe('site App', function() { describe('404 page', () => { it('should add or remove the "noindex" meta tag depending upon the validity of the page', () => { page.navigateTo(''); - expect(element(by.css('meta[name="googlebot"]')).isPresent()).toBeFalsy(); expect(element(by.css('meta[name="robots"]')).isPresent()).toBeFalsy(); page.navigateTo('does/not/exist'); - expect(element(by.css('meta[name="googlebot"][content="noindex"]')).isPresent()).toBeTruthy(); expect(element(by.css('meta[name="robots"][content="noindex"]')).isPresent()).toBeTruthy(); page.click(page.getTopMenuLink('features')); - expect(element(by.css('meta[name="googlebot"]')).isPresent()).toBeFalsy(); expect(element(by.css('meta[name="robots"]')).isPresent()).toBeFalsy(); }); 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 6643f1d5e0..f2668dae20 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 @@ -1,6 +1,6 @@ import { ComponentRef } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { Title, Meta } from '@angular/platform-browser'; +import { Meta, Title } from '@angular/platform-browser'; import { Observable } from 'rxjs/Observable'; import { of } from 'rxjs/observable/of'; @@ -415,21 +415,18 @@ describe('DocViewerComponent', () => { expect(addTitleAndTocSpy).toHaveBeenCalledTimes(4); }); - it('should remove "noindex" meta tags if the document is valid', async () => { + it('should remove the "noindex" meta tag if the document is valid', async () => { await doRender('foo', 'bar'); - expect(TestBed.get(Meta).removeTag).toHaveBeenCalledWith('name="googlebot"'); expect(TestBed.get(Meta).removeTag).toHaveBeenCalledWith('name="robots"'); }); - it('should add "noindex" meta tags if the document is 404', async () => { + it('should add the "noindex" meta tag if the document is 404', async () => { await doRender('missing', FILE_NOT_FOUND_ID); - expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'googlebot', content: 'noindex' }); expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'robots', content: 'noindex' }); }); - it('should add "noindex" meta tags if the document fetching fails', async () => { + it('should add a "noindex" meta tag if the document fetching fails', async () => { await doRender('error', FETCHING_ERROR_ID); - expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'googlebot', content: 'noindex' }); expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'robots', content: 'noindex' }); }); }); @@ -558,7 +555,6 @@ describe('DocViewerComponent', () => { [jasmine.any(Error)] ]); expect(logger.output.error[0][0].message).toEqual(`[DocViewer] Error preparing document 'foo': ${error.stack}`); - expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'googlebot', content: 'noindex' }); expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'robots', content: 'noindex' }); }); @@ -580,7 +576,6 @@ describe('DocViewerComponent', () => { [jasmine.any(Error)] ]); expect(logger.output.error[0][0].message).toEqual(`[DocViewer] Error preparing document 'bar': ${error.stack}`); - expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'googlebot', content: 'noindex' }); expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'robots', content: 'noindex' }); }); @@ -602,7 +597,6 @@ describe('DocViewerComponent', () => { [jasmine.any(Error)] ]); expect(logger.output.error[0][0].message).toEqual(`[DocViewer] Error preparing document 'baz': ${error.stack}`); - expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'googlebot', content: 'noindex' }); expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'robots', content: 'noindex' }); }); @@ -624,7 +618,6 @@ describe('DocViewerComponent', () => { [jasmine.any(Error)] ]); expect(logger.output.error[0][0].message).toEqual(`[DocViewer] Error preparing document 'qux': ${error.stack}`); - expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'googlebot', content: 'noindex' }); expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'robots', content: 'noindex' }); }); @@ -643,7 +636,6 @@ describe('DocViewerComponent', () => { [jasmine.any(Error)] ]); expect(logger.output.error[0][0].message).toEqual(`[DocViewer] Error preparing document 'qux': ${error}`); - expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'googlebot', content: 'noindex' }); expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'robots', content: 'noindex' }); }); });