Skip to content

Commit

Permalink
test(aio): fix DocViewerComponent tests (#23359)
Browse files Browse the repository at this point in the history
Obsolete assertions left over from #23249.

PR Close #23359
  • Loading branch information
gkalpak authored and IgorMinar committed Apr 13, 2018
1 parent 75d1ab9 commit a3204f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
3 changes: 0 additions & 3 deletions aio/e2e/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
16 changes: 4 additions & 12 deletions aio/src/app/layout/doc-viewer/doc-viewer.component.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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' });
});
});
Expand Down Expand Up @@ -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' });
});

Expand All @@ -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' });
});

Expand All @@ -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' });
});

Expand All @@ -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' });
});

Expand All @@ -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' });
});
});
Expand Down

0 comments on commit a3204f8

Please sign in to comment.