Skip to content

Commit

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

PR Close angular#23359
  • Loading branch information
gkalpak authored and wKoza committed Apr 13, 2018
1 parent d0baf4e commit 683f94c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
15 changes: 4 additions & 11 deletions aio/src/app/layout/doc-viewer/doc-viewer.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Title, Meta } from '@angular/platform-browser';
import { Meta, Title } from '@angular/platform-browser';

import { Observable, of } from 'rxjs';

Expand Down Expand Up @@ -367,21 +367,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 @@ -475,7 +472,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 @@ -495,7 +491,6 @@ describe('DocViewerComponent', () => {
expect(logger.output.error).toEqual([
[jasmine.any(Error)]
]);
expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'googlebot', content: 'noindex' });
expect(TestBed.get(Meta).addTag).toHaveBeenCalledWith({ name: 'robots', content: 'noindex' });
});

Expand All @@ -515,7 +510,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 @@ -534,7 +528,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
3 changes: 0 additions & 3 deletions aio/tests/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

0 comments on commit 683f94c

Please sign in to comment.