test(docs-infra): fix tests (#26202)

PR Close #26202
This commit is contained in:
George Kalpakas 2018-10-02 12:42:10 +03:00 committed by Jason Aden
parent b46fa92ae5
commit 10e414f617
6 changed files with 9 additions and 13 deletions

View File

@ -44,7 +44,7 @@ describe('ContributorService', () => {
it('contributors observable should complete', () => { it('contributors observable should complete', () => {
let completed = false; let completed = false;
contribService.contributors.subscribe(undefined, undefined, () => completed = true); 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', () => { it('should reshape the contributor json to expected result', () => {

View File

@ -44,7 +44,7 @@ describe('ResourceService', () => {
it('categories observable should complete', () => { it('categories observable should complete', () => {
let completed = false; let completed = false;
resourceService.categories.subscribe(undefined, undefined, () => completed = true); 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', () => { it('should reshape contributors.json to sorted category array', () => {

View File

@ -138,9 +138,6 @@ describe('TocComponent', () => {
}); });
it('should have more than 4 displayed items', () => { it('should have more than 4 displayed items', () => {
let tocList: TocItem[];
tocService.tocList.subscribe(v => tocList = v);
expect(page.listItems.length).toBeGreaterThan(4); expect(page.listItems.length).toBeGreaterThan(4);
}); });

View File

@ -180,10 +180,8 @@ describe('DocumentService', () => {
describe('computeMap', () => { describe('computeMap', () => {
it('should map the "empty" location to the correct document request', () => { it('should map the "empty" location to the correct document request', () => {
let latestDocument: DocumentContents;
const { docService } = getServices(); const { docService } = getServices();
docService.currentDocument.subscribe();
docService.currentDocument.subscribe(doc => latestDocument = doc);
httpMock.expectOne(CONTENT_URL_PREFIX + 'index.json'); httpMock.expectOne(CONTENT_URL_PREFIX + 'index.json');
}); });

View File

@ -2,7 +2,9 @@ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/
import { Injector } from '@angular/core'; import { Injector } from '@angular/core';
import { TestBed } from '@angular/core/testing'; 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 { LocationService } from 'app/shared/location.service';
import { MockLocationService } from 'testing/location.service'; import { MockLocationService } from 'testing/location.service';
@ -46,10 +48,9 @@ describe('NavigationService', () => {
it('navigationViews observable should complete', () => { it('navigationViews observable should complete', () => {
let completed = false; let completed = false;
navService.navigationViews.subscribe(undefined, undefined, () => completed = true); navService.navigationViews.subscribe(undefined, undefined, () => completed = true);
expect(true).toBe(true, 'observable completed');
// Stop `$httpMock.verify()` from complaining. httpMock.expectOne({method: 'get', url: navigationPath}).flush({});
httpMock.expectOne({}); expect(completed).toBe(true, 'observable completed');
}); });
it('should return the same object to all subscribers', () => { it('should return the same object to all subscribers', () => {

View File

@ -11,7 +11,7 @@ import { CONTENT_URL_PREFIX } from 'app/documents/document.service';
import { CurrentNodes, NavigationNode, NavigationResponse, NavigationViews, VersionInfo } from './navigation.model'; import { CurrentNodes, NavigationNode, NavigationResponse, NavigationViews, VersionInfo } from './navigation.model';
export { CurrentNodes, CurrentNode, 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() @Injectable()
export class NavigationService { export class NavigationService {