Skip to content

Commit 0075505

Browse files
committed
Fix all types in tests
1 parent 93ec784 commit 0075505

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

__tests__/neovis.tests.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('Neovis', () => {
5050
}
5151
};
5252
const neovis = new Neovis(config as NeovisConfig);
53-
expect(neovis._config.labels.a).toMatchObject({ label: 'name', chosen: 'test' });
53+
expect(neovis._config.labels!.a).toMatchObject({ label: 'name', chosen: 'test' });
5454
});
5555
it('should not change the config sent', () => {
5656
config = {
@@ -87,7 +87,7 @@ describe('Neovis', () => {
8787
}
8888
};
8989
const neovis = new Neovis(config as NeovisConfig);
90-
expect(neovis._config.relationships.a).toMatchObject({
90+
expect(neovis._config.relationships!.a).toMatchObject({
9191
label: 'name', color: 'test', chosen: 'overridden'
9292
});
9393
});
@@ -101,7 +101,7 @@ describe('Neovis', () => {
101101
}
102102
};
103103
const neovis = new Neovis(config as NeovisConfig);
104-
expect(neovis._config.labels.a).toMatchObject({ label: 'name', chosen: 'test' });
104+
expect(neovis._config.labels!.a).toMatchObject({ label: 'name', chosen: 'test' });
105105
});
106106
it('should override default config if specific relationship have one', () => {
107107
config.relationships = {
@@ -115,7 +115,7 @@ describe('Neovis', () => {
115115
}
116116
};
117117
const neovis = new Neovis(config as NeovisConfig);
118-
expect(neovis._config.relationships.a).toMatchObject({
118+
expect(neovis._config.relationships!.a).toMatchObject({
119119
label: 'name', value: 'test', chosen: 'overridden'
120120
});
121121
});
@@ -206,9 +206,9 @@ describe('Neovis', () => {
206206
]);
207207
neovis.render();
208208
await testUtils.neovisRenderDonePromise(neovis);
209-
expect(neovis.nodes.get(1).raw).toBeDefined();
210-
expect(neovis.nodes.get(2).raw).toBeDefined();
211-
expect(neovis.edges.get(3).raw).toBeDefined();
209+
expect(neovis.nodes.get(1)!.raw).toBeDefined();
210+
expect(neovis.nodes.get(2)!.raw).toBeDefined();
211+
expect(neovis.edges.get(3)!.raw).toBeDefined();
212212
});
213213
});
214214

@@ -371,9 +371,9 @@ describe('Neovis', () => {
371371

372372
neovis.render();
373373
await testUtils.neovisRenderDonePromise(neovis);
374-
expect(neovis.nodes.get(1).font).toBeDefined();
375-
expect((neovis.nodes.get(1).font as VisNetwork.Font).size).toBe(fontSize);
376-
expect((neovis.nodes.get(1).font as VisNetwork.Font).color).toBe(fontColor);
374+
expect(neovis.nodes.get(1)!.font).toBeDefined();
375+
expect((neovis.nodes.get(1)!.font as VisNetwork.Font).size).toBe(fontSize);
376+
expect((neovis.nodes.get(1)!.font as VisNetwork.Font).color).toBe(fontColor);
377377
});
378378

379379
it('font field for type not specified in config should not reflect in node data', async () => {
@@ -420,8 +420,8 @@ describe('Neovis', () => {
420420
await testUtils.neovisRenderDonePromise(neovis);
421421
expect(Neo4jMock.mockSessionRun).toHaveBeenCalledTimes(1);
422422
expect(neovis.nodes.get(1)).toHaveProperty('font');
423-
expect(neovis.nodes.get(1).font).toHaveProperty('size', intPropertyValue);
424-
expect(neovis.nodes.get(1).font).toHaveProperty('color', intPropertyValue);
423+
expect(neovis.nodes.get(1)!.font).toHaveProperty('size', intPropertyValue);
424+
expect(neovis.nodes.get(1)!.font).toHaveProperty('color', intPropertyValue);
425425
});
426426

427427
it('should merge static type to vis.js config properly', async () => {

__tests__/testUtils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ export function mockNormalRunSubscribe(records: Neo4jType.Record<{ [key: string]
6969
}
7070

7171
export function mockFullRunSubscribe(cypherIdsAndAnswers: Record<string, { default?: Neo4jType.Record<{ [key: string]: unknown }>[], [id: number]: Neo4jType.Record<{ [key: string]: unknown }>[] } >): void {
72-
Neo4jMock.mockSessionRun.mockImplementation((cypher: string, parameters: { id: number}) => {
72+
Neo4jMock.mockSessionRun.mockImplementation((cypher: string, parameters: Record<string, unknown>) => {
7373
if (!cypherIdsAndAnswers[cypher]) {
7474
throw new Error(`the cypher '${cypher}' was not expected`);
7575
}
76-
if (!cypherIdsAndAnswers[cypher].default && !cypherIdsAndAnswers[cypher][parameters.id]) {
76+
if (!cypherIdsAndAnswers[cypher].default && !cypherIdsAndAnswers[cypher][parameters.id as number]) {
7777
throw new Error(`the id '${parameters.id}' was not expected for cypher ${cypher}`);
7878
}
79-
const records = cypherIdsAndAnswers[cypher].default || cypherIdsAndAnswers[cypher][parameters.id];
79+
const records = cypherIdsAndAnswers[cypher].default || cypherIdsAndAnswers[cypher][parameters.id as number];
8080
const observablePromise: Partial<ObservablePromise<{ records: Neo4jType.Record<{ [key: string]: unknown }>[] }>> = Promise.resolve({ records });
8181
observablePromise.subscribe = ({ onNext, onCompleted }) => {
8282
records.forEach(onNext);

0 commit comments

Comments
 (0)