From 10e414f61779661f18c44cfe9c95c9d8eb1a7320 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Tue, 2 Oct 2018 12:42:10 +0300 Subject: [PATCH] test(docs-infra): fix tests (#26202) PR Close #26202 --- .../contributor/contributor.service.spec.ts | 2 +- .../custom-elements/resource/resource.service.spec.ts | 2 +- aio/src/app/custom-elements/toc/toc.component.spec.ts | 3 --- aio/src/app/documents/document.service.spec.ts | 4 +--- aio/src/app/navigation/navigation.service.spec.ts | 9 +++++---- aio/src/app/navigation/navigation.service.ts | 2 +- 6 files changed, 9 insertions(+), 13 deletions(-) diff --git a/aio/src/app/custom-elements/contributor/contributor.service.spec.ts b/aio/src/app/custom-elements/contributor/contributor.service.spec.ts index 909b3cf60b..cdf6151757 100644 --- a/aio/src/app/custom-elements/contributor/contributor.service.spec.ts +++ b/aio/src/app/custom-elements/contributor/contributor.service.spec.ts @@ -44,7 +44,7 @@ describe('ContributorService', () => { it('contributors observable should complete', () => { let completed = false; contribService.contributors.subscribe(undefined, undefined, () => completed = true); - expect(true).toBe(true, 'observable completed'); + expect(completed).toBe(true, 'observable completed'); }); it('should reshape the contributor json to expected result', () => { diff --git a/aio/src/app/custom-elements/resource/resource.service.spec.ts b/aio/src/app/custom-elements/resource/resource.service.spec.ts index 317115c0b6..e376268df6 100644 --- a/aio/src/app/custom-elements/resource/resource.service.spec.ts +++ b/aio/src/app/custom-elements/resource/resource.service.spec.ts @@ -44,7 +44,7 @@ describe('ResourceService', () => { it('categories observable should complete', () => { let completed = false; resourceService.categories.subscribe(undefined, undefined, () => completed = true); - expect(true).toBe(true, 'observable completed'); + expect(completed).toBe(true, 'observable completed'); }); it('should reshape contributors.json to sorted category array', () => { diff --git a/aio/src/app/custom-elements/toc/toc.component.spec.ts b/aio/src/app/custom-elements/toc/toc.component.spec.ts index c7f228724f..f31bc26d99 100644 --- a/aio/src/app/custom-elements/toc/toc.component.spec.ts +++ b/aio/src/app/custom-elements/toc/toc.component.spec.ts @@ -138,9 +138,6 @@ describe('TocComponent', () => { }); it('should have more than 4 displayed items', () => { - let tocList: TocItem[]; - tocService.tocList.subscribe(v => tocList = v); - expect(page.listItems.length).toBeGreaterThan(4); }); diff --git a/aio/src/app/documents/document.service.spec.ts b/aio/src/app/documents/document.service.spec.ts index ab2f56d28c..1896c1c9a8 100644 --- a/aio/src/app/documents/document.service.spec.ts +++ b/aio/src/app/documents/document.service.spec.ts @@ -180,10 +180,8 @@ describe('DocumentService', () => { describe('computeMap', () => { it('should map the "empty" location to the correct document request', () => { - let latestDocument: DocumentContents; const { docService } = getServices(); - - docService.currentDocument.subscribe(doc => latestDocument = doc); + docService.currentDocument.subscribe(); httpMock.expectOne(CONTENT_URL_PREFIX + 'index.json'); }); diff --git a/aio/src/app/navigation/navigation.service.spec.ts b/aio/src/app/navigation/navigation.service.spec.ts index 4120d43118..0fe14590c7 100644 --- a/aio/src/app/navigation/navigation.service.spec.ts +++ b/aio/src/app/navigation/navigation.service.spec.ts @@ -2,7 +2,9 @@ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/ import { Injector } from '@angular/core'; import { TestBed } from '@angular/core/testing'; -import { CurrentNodes, NavigationService, NavigationViews, NavigationNode, VersionInfo } from 'app/navigation/navigation.service'; +import { + CurrentNodes, NavigationNode, navigationPath, NavigationService, NavigationViews, VersionInfo, +} from 'app/navigation/navigation.service'; import { LocationService } from 'app/shared/location.service'; import { MockLocationService } from 'testing/location.service'; @@ -46,10 +48,9 @@ describe('NavigationService', () => { it('navigationViews observable should complete', () => { let completed = false; navService.navigationViews.subscribe(undefined, undefined, () => completed = true); - expect(true).toBe(true, 'observable completed'); - // Stop `$httpMock.verify()` from complaining. - httpMock.expectOne({}); + httpMock.expectOne({method: 'get', url: navigationPath}).flush({}); + expect(completed).toBe(true, 'observable completed'); }); it('should return the same object to all subscribers', () => { diff --git a/aio/src/app/navigation/navigation.service.ts b/aio/src/app/navigation/navigation.service.ts index 3b42083b56..eaf2a710c7 100644 --- a/aio/src/app/navigation/navigation.service.ts +++ b/aio/src/app/navigation/navigation.service.ts @@ -11,7 +11,7 @@ import { CONTENT_URL_PREFIX } from 'app/documents/document.service'; import { CurrentNodes, NavigationNode, NavigationResponse, NavigationViews, VersionInfo } from './navigation.model'; export { CurrentNodes, CurrentNode, NavigationNode, NavigationResponse, NavigationViews, VersionInfo } from './navigation.model'; -const navigationPath = CONTENT_URL_PREFIX + 'navigation.json'; +export const navigationPath = CONTENT_URL_PREFIX + 'navigation.json'; @Injectable() export class NavigationService {