Skip to content

Commit 9a21384

Browse files
committed
Add tests for protocol v2
1 parent f5eb66f commit 9a21384

File tree

4 files changed

+435
-2
lines changed

4 files changed

+435
-2
lines changed

packages/bolt-connection/src/bolt/bolt-protocol-v2.transformer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ function createDateTimeWithOffsetTransformer ({ disableLosslessIntegers, useBigI
320320
return new structure.Structure(DATE_TIME_WITH_ZONE_OFFSET, [epochSecond, nano, timeZoneOffsetSeconds])
321321
},
322322
fromStructure: struct => {
323-
struct.verifyStructSize(
323+
structure.verifyStructSize(
324324
'DateTimeWithZoneOffset',
325325
DATE_TIME_WITH_ZONE_OFFSET_STRUCT_SIZE,
326326
struct.size
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`#unit BoltProtocolV2 .packable() should pack not pack graph types (Node) 1`] = `"It is not allowed to pass nodes in query parameters, given: (c:a {a:\\"b\\"})"`;
4+
5+
exports[`#unit BoltProtocolV2 .packable() should pack not pack graph types (Path) 1`] = `"It is not allowed to pass paths in query parameters, given: [object Object]"`;
6+
7+
exports[`#unit BoltProtocolV2 .packable() should pack not pack graph types (PathSegment) 1`] = `"Cannot read properties of null (reading 'writeUInt8')"`;
8+
9+
exports[`#unit BoltProtocolV2 .packable() should pack not pack graph types (Relationship) 1`] = `"It is not allowed to pass relationships in query parameters, given: (e)-[:a {b:\\"c\\"}]->(f)"`;
10+
11+
exports[`#unit BoltProtocolV2 .packable() should pack not pack graph types (UnboundRelationship) 1`] = `"It is not allowed to pass unbound relationships in query parameters, given: -[:a {b:\\"c\\"}]->"`;
12+
13+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(Date with less fields) 1`] = `"Wrong struct size for Date, expected 1 but was 0"`;
14+
15+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(Date with more fields) 1`] = `"Wrong struct size for Date, expected 1 but was 2"`;
16+
17+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(DateTimeWithZoneId with less fields) 1`] = `"Wrong struct size for DateTimeWithZoneId, expected 3 but was 2"`;
18+
19+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(DateTimeWithZoneId with more fields) 1`] = `"Wrong struct size for DateTimeWithZoneId, expected 3 but was 4"`;
20+
21+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(DateTimeWithZoneOffset with less fields) 1`] = `"Wrong struct size for DateTimeWithZoneOffset, expected 3 but was 2"`;
22+
23+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(DateTimeWithZoneOffset with more fields) 1`] = `"Wrong struct size for DateTimeWithZoneOffset, expected 3 but was 4"`;
24+
25+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(Duration with less fields) 1`] = `"Wrong struct size for Duration, expected 4 but was 3"`;
26+
27+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(Duration with more fields) 1`] = `"Wrong struct size for Duration, expected 4 but was 5"`;
28+
29+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(LocalDateTime with less fields) 1`] = `"Wrong struct size for LocalDateTime, expected 2 but was 1"`;
30+
31+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(LocalDateTime with more fields) 1`] = `"Wrong struct size for LocalDateTime, expected 2 but was 3"`;
32+
33+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(LocalTime with less fields) 1`] = `"Wrong struct size for LocalTime, expected 1 but was 0"`;
34+
35+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(LocalTime with more fields) 1`] = `"Wrong struct size for LocalTime, expected 1 but was 2"`;
36+
37+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(Node with less fields) 1`] = `"Wrong struct size for Node, expected 3 but was 2"`;
38+
39+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(Node with more fields) 1`] = `"Wrong struct size for Node, expected 3 but was 4"`;
40+
41+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(Path with less fields) 1`] = `"Wrong struct size for Path, expected 3 but was 2"`;
42+
43+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(Path with more fields) 1`] = `"Wrong struct size for Path, expected 3 but was 4"`;
44+
45+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(Point with less fields) 1`] = `"Wrong struct size for Point2D, expected 3 but was 2"`;
46+
47+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(Point with more fields) 1`] = `"Wrong struct size for Point2D, expected 3 but was 4"`;
48+
49+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(Point3D with less fields) 1`] = `"Wrong struct size for Point3D, expected 4 but was 3"`;
50+
51+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(Point3D with more fields) 1`] = `"Wrong struct size for Point3D, expected 4 but was 5"`;
52+
53+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(Relationship with less fields) 1`] = `"Wrong struct size for Relationship, expected 5 but was 4"`;
54+
55+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(Relationship with more fields) 1`] = `"Wrong struct size for Relationship, expected 5 but was 8"`;
56+
57+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(Time with less fields) 1`] = `"Wrong struct size for Time, expected 2 but was 1"`;
58+
59+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(Time with more fileds) 1`] = `"Wrong struct size for Time, expected 2 but was 3"`;
60+
61+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(UnboundRelationship with less fields) 1`] = `"Wrong struct size for UnboundRelationship, expected 3 but was 2"`;
62+
63+
exports[`#unit BoltProtocolV2 .unpack() should not unpack with wrong size(UnboundRelationship with more fields) 1`] = `"Wrong struct size for UnboundRelationship, expected 3 but was 4"`;

packages/bolt-connection/test/bolt/bolt-protocol-v1.test.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,21 @@
1919

2020
import BoltProtocolV1 from '../../src/bolt/bolt-protocol-v1'
2121
import RequestMessage from '../../src/bolt/request-message'
22-
import { Date, DateTime, Duration, internal, LocalDateTime, LocalTime, Path, PathSegment, Point, Relationship, Time, UnboundRelationship, Node } from 'neo4j-driver-core'
22+
import {
23+
Date,
24+
DateTime,
25+
Duration,
26+
internal,
27+
LocalDateTime,
28+
LocalTime,
29+
Path,
30+
PathSegment,
31+
Point,
32+
Relationship,
33+
Time,
34+
UnboundRelationship,
35+
Node
36+
} from 'neo4j-driver-core'
2337
import utils from '../test-utils'
2438
import { LoginObserver } from '../../src/bolt/stream-observers'
2539
import { alloc } from '../../src/channel'
@@ -406,6 +420,7 @@ describe('#unit BoltProtocolV1', () => {
406420
buffer.reset()
407421

408422
const unpacked = protocol.unpack(buffer)
423+
expect(unpacked).toBeInstanceOf(Object)
409424
expect(unpacked).toMatchSnapshot()
410425
})
411426
})

0 commit comments

Comments
 (0)