fix(aio): fix up typing errors in tests
The new version of Jasmine types identified issues with our unit tests.
This commit is contained in:
parent
faacbe4dac
commit
39f2977fa8
|
@ -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));
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -24,7 +24,7 @@ export interface NavigationViews {
|
|||
*/
|
||||
export interface CurrentNode {
|
||||
url: string;
|
||||
view: 'SideNav' | 'TopBar' | 'Footer';
|
||||
view: string;
|
||||
nodes: NavigationNode[];
|
||||
}
|
||||
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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]
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue