Skip to content

Commit d1d0b4f

Browse files
committed
Merge branch 'feature/move-to-ts' into 2.0.0
2 parents d3d063b + ce11fc6 commit d1d0b4f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+6368
-12009
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ examples
44
doc
55
dist
66
webpack.config.js
7-
*.ts
7+
*.d.ts
88
babel.config.js

.eslintrc.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
parser: "@babel/eslint-parser"
1+
parser: "@typescript-eslint/parser"
22
env:
33
browser: true
44
es6: true
55
"jest/globals": true
66
extends:
77
- 'eslint:recommended'
88
- 'plugin:jest/recommended'
9+
- 'plugin:@typescript-eslint/recommended'
910
globals:
1011
Atomics: readonly
1112
SharedArrayBuffer: readonly
@@ -16,6 +17,7 @@ ignorePatterns:
1617
- docs/
1718
plugins:
1819
- jest
20+
- '@typescript-eslint'
1921
rules:
2022
indent:
2123
- error
@@ -34,3 +36,4 @@ rules:
3436
- always
3537
jest/no-mocks-import:
3638
- error
39+
"@typescript-eslint/ban-types": off

__mocks__/neo4j-driver.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
1-
const Neo4j = jest.requireActual('neo4j-driver');
1+
import type * as Neo4jType from 'neo4j-driver';
2+
import { ObservablePromise } from '../__tests__/testUtils';
3+
const Neo4j: typeof Neo4jType = jest.requireActual('neo4j-driver');
24

3-
export const mockSessionRun = jest.fn(() => {
4-
const observablePromise = Promise.resolve();
5+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
6+
export const mockSessionRun: jest.Mock<ObservablePromise<unknown>, [cypher: string, b: Record<string, unknown>]> = jest.fn((..._) => {
7+
const observablePromise: Partial<ObservablePromise<void>> = Promise.resolve();
8+
// eslint-disable-next-line @typescript-eslint/no-empty-function
59
observablePromise.subscribe = jest.fn(() => {});
6-
return observablePromise;
10+
return observablePromise as ObservablePromise<void>;
711
});
812

13+
// eslint-disable-next-line @typescript-eslint/no-empty-function
914
export const mockSessionClose = jest.fn().mockImplementation(() => {});
1015

11-
export const mockReadTransaction = jest.fn(function (callback) {
16+
export const mockReadTransaction = jest.fn(function (this: Neo4jType.Session, callback: (session: Neo4jType.Session) => void) {
1217
return callback(this);
1318
});
1419

15-
export const mockSession = jest.fn().mockImplementation(() => ({
20+
export const mockSession: jest.Mock<Partial<Neo4jType.Session>> = jest.fn().mockImplementation(() => ({
1621
run: mockSessionRun,
1722
close: mockSessionClose,
1823
readTransaction: mockReadTransaction
1924
}));
2025

2126
export const mockDriver = jest.spyOn(Neo4j, 'driver').mockImplementation(() => ({
22-
session: mockSession
23-
}));
27+
session: mockSession as unknown as (...args: unknown[]) => Neo4jType.Session
28+
}) as Neo4jType.Driver);
2429

25-
export function clearAllMocks() {
30+
export function clearAllMocks(): void {
2631
mockSessionClose.mockClear();
2732
mockSessionRun.mockClear();
2833
mockSession.mockClear();

0 commit comments

Comments
 (0)