diff --git a/aio/src/app/embedded/api/api.service.spec.ts b/aio/src/app/embedded/api/api.service.spec.ts index 51f6452c87..c7bf9b060c 100644 --- a/aio/src/app/embedded/api/api.service.spec.ts +++ b/aio/src/app/embedded/api/api.service.spec.ts @@ -54,7 +54,7 @@ describe('ApiService', () => { describe('#sections', () => { it('first subscriber should fetch sections', () => { - const data = [{name: 'a'}, {name: 'b'}]; + const data = [{name: 'a', title: 'A', items: []}, {name: 'b', title: 'B', items: []}]; service.sections.subscribe(sections => { expect(sections).toEqual(data); @@ -64,7 +64,7 @@ describe('ApiService', () => { }); it('second subscriber should get previous sections and NOT trigger refetch', () => { - const data = [{name: 'a'}, {name: 'b'}]; + const data = [{name: 'a', title: 'A', items: []}, {name: 'b', title: 'B', items: []}]; let subscriptions = 0; service.sections.subscribe(sections => { @@ -99,7 +99,7 @@ describe('ApiService', () => { let connection: MockConnection; backend.connections.subscribe(c => connection = c); - let data = [{name: 'a'}, {name: 'b'}]; + let data = [{name: 'a', title: 'A', items: []}, {name: 'b', title: 'B', items: []}]; service.sections.subscribe(sections => { // called twice during this test @@ -110,7 +110,7 @@ describe('ApiService', () => { connection.mockRespond(createResponse(data)); // refresh/refetch - data = [{name: 'c'}]; + data = [{name: 'c', title: 'C', items: []}]; service.fetchSections(); connection.mockRespond(createResponse(data)); diff --git a/aio/src/app/embedded/code/code-example.component.spec.ts b/aio/src/app/embedded/code/code-example.component.spec.ts index 698adc2702..ce57a96106 100644 --- a/aio/src/app/embedded/code/code-example.component.spec.ts +++ b/aio/src/app/embedded/code/code-example.component.spec.ts @@ -87,7 +87,7 @@ describe('CodeExampleComponent', () => { class TestCodeComponent { @Input() code = ''; @Input() language: string; - @Input() linenums: boolean | number; + @Input() linenums: string; @Input() path: string; @Input() region: string; @Input() hideCopy: boolean; diff --git a/aio/src/app/embedded/code/code-example.component.ts b/aio/src/app/embedded/code/code-example.component.ts index 95d954f840..9e9cad1dbb 100644 --- a/aio/src/app/embedded/code/code-example.component.ts +++ b/aio/src/app/embedded/code/code-example.component.ts @@ -26,7 +26,7 @@ export class CodeExampleComponent implements OnInit { classes: {}; code: string; language: string; - linenums: boolean | number; + linenums: string; path: string; region: string; title: string; @@ -36,7 +36,7 @@ export class CodeExampleComponent implements OnInit { isAvoid = false; constructor(private elementRef: ElementRef) { - const element = this.elementRef.nativeElement; + const element: HTMLElement = this.elementRef.nativeElement; this.language = element.getAttribute('language') || ''; this.linenums = element.getAttribute('linenums'); diff --git a/aio/src/app/navigation/navigation.model.ts b/aio/src/app/navigation/navigation.model.ts index 4bf10d4f04..0873fa3632 100644 --- a/aio/src/app/navigation/navigation.model.ts +++ b/aio/src/app/navigation/navigation.model.ts @@ -24,7 +24,7 @@ export interface NavigationViews { */ export interface CurrentNode { url: string; - view: 'SideNav' | 'TopBar' | 'Footer'; + view: string; nodes: NavigationNode[]; } diff --git a/aio/src/app/navigation/navigation.service.spec.ts b/aio/src/app/navigation/navigation.service.spec.ts index dcf38469ad..be6bece23d 100644 --- a/aio/src/app/navigation/navigation.service.spec.ts +++ b/aio/src/app/navigation/navigation.service.spec.ts @@ -91,7 +91,7 @@ describe('NavigationService', () => { ]; beforeEach(() => { - navService.navigationViews.subscribe(views => view = views.sideNav); + navService.navigationViews.subscribe(views => view = views['sideNav']); backend.connectionsArray[0].mockRespond(createResponse({sideNav})); }); @@ -191,7 +191,7 @@ describe('NavigationService', () => { }); it('should ignore trailing slashes, hashes, and search params on URLs in the navmap', () => { - const cnode = { + const cnode: CurrentNode = { url: 'c', view: 'SideNav', nodes: [ @@ -216,17 +216,18 @@ describe('NavigationService', () => { }); describe('versionInfo', () => { + const expectedVersionInfo = { raw: '4.0.0' } as VersionInfo; let versionInfo: VersionInfo; beforeEach(() => { navService.versionInfo.subscribe(info => versionInfo = info); backend.connectionsArray[0].mockRespond(createResponse({ - __versionInfo: { raw: '4.0.0' } + __versionInfo: expectedVersionInfo })); }); it('should extract the version info', () => { - expect(versionInfo).toEqual({ raw: '4.0.0' }); + expect(versionInfo).toEqual(expectedVersionInfo); }); }); @@ -246,7 +247,7 @@ describe('NavigationService', () => { {...v, ...{ tooltip: v.title + '.'}}) ); - navService.navigationViews.subscribe(views => actualDocVersions = views.docVersions); + navService.navigationViews.subscribe(views => actualDocVersions = views['docVersions']); }); it('should extract the docVersions', () => { diff --git a/aio/src/app/shared/location.service.spec.ts b/aio/src/app/shared/location.service.spec.ts index 72862e61e3..55a78a92c6 100644 --- a/aio/src/app/shared/location.service.spec.ts +++ b/aio/src/app/shared/location.service.spec.ts @@ -278,7 +278,7 @@ describe('LocationService', () => { service.go(testUrl); expect(url).toEqual(initialUrl, 'should not have re-navigated locally'); - expect(goExternalSpy.wasCalled).toBeFalsy('should not have navigated externally'); + expect(goExternalSpy).not.toHaveBeenCalled(); }; } diff --git a/aio/src/app/shared/toc.service.spec.ts b/aio/src/app/shared/toc.service.spec.ts index 9232e3ba82..15b3217319 100644 --- a/aio/src/app/shared/toc.service.spec.ts +++ b/aio/src/app/shared/toc.service.spec.ts @@ -32,6 +32,8 @@ describe('TocService', () => { describe('tocList', () => { it('should emit the latest value to new subscribers', () => { + const expectedValue1 = {} as TocItem; + const expectedValue2 = {} as TocItem; let value1: TocItem[]; let value2: TocItem[]; @@ -39,21 +41,23 @@ describe('TocService', () => { tocService.tocList.subscribe(v => value1 = v); expect(value1).toEqual([]); - tocService.tocList.next([{}, {}] as TocItem[]); + tocService.tocList.next([expectedValue1, expectedValue2] as TocItem[]); tocService.tocList.subscribe(v => value2 = v); - expect(value2).toEqual([{}, {}]); + expect(value2).toEqual([expectedValue1, expectedValue2]); }); it('should emit the same values to all subscribers', () => { + const expectedValue1 = {} as TocItem; + const expectedValue2 = {} as TocItem; const emittedValues: TocItem[][] = []; tocService.tocList.subscribe(v => emittedValues.push(v)); tocService.tocList.subscribe(v => emittedValues.push(v)); - tocService.tocList.next([{ title: 'A' }, { title: 'B' }] as TocItem[]); + tocService.tocList.next([expectedValue1, expectedValue2] as TocItem[]); expect(emittedValues).toEqual([ - [{ title: 'A' }, { title: 'B' }], - [{ title: 'A' }, { title: 'B' }] + [expectedValue1, expectedValue2], + [expectedValue1, expectedValue2] ]); }); });