Skip to content

Commit b1037a3

Browse files
committed
mock gremlin client in driver unit tests
1 parent 216a36d commit b1037a3

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test/unit/driver/aws-sigv4-driver-remote-connection.test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/* eslint-disable-line no-new */
22
const gremlin = require('gremlin');
3-
43
const utils = require('../../../lib/utils');
4+
const AwsSigV4DriverRemoteConnection = require('../../../lib/driver/aws-sigv4-driver-remote-connection');
55

6+
jest.mock('gremlin');
67
jest.mock('../../../lib/utils', () => ({
78
...jest.requireActual('../../../lib/utils'),
89
request: jest.fn(),
910
}));
1011

11-
const AwsSigV4DriverRemoteConnection = require('../../../lib/driver/aws-sigv4-driver-remote-connection');
12-
1312
const HOST = 'aws.dev.gremlin';
1413
const PORT = 8182;
1514
const OPTS = {
@@ -21,6 +20,15 @@ const OPTS = {
2120
describe('AwsSigV4DriverRemoteConnection', () => {
2221
afterEach(() => {
2322
jest.resetAllMocks();
23+
gremlin.driver.Client.mockImplementation((url) => ({
24+
_connection: {
25+
url,
26+
on: jest.fn(),
27+
_ws: {
28+
on: jest.fn(),
29+
},
30+
},
31+
}));
2432
});
2533

2634
describe('constructor', () => {
@@ -32,7 +40,7 @@ describe('AwsSigV4DriverRemoteConnection', () => {
3240

3341
it('should accept options', () => {
3442
const connection = new AwsSigV4DriverRemoteConnection(HOST, PORT, OPTS);
35-
expect(connection.url).toEqual(`ws://${HOST}:${PORT}/gremlin`);
43+
expect(connection.options).toEqual(OPTS);
3644
});
3745
});
3846

0 commit comments

Comments
 (0)