Skip to content

Commit 441899a

Browse files
authored
Merge pull request #203 from thebestnom/feature/remove-snake-case
Migrate snake_case to camelCase
2 parents 80d2583 + b283972 commit 441899a

File tree

10 files changed

+130
-105
lines changed

10 files changed

+130
-105
lines changed

MIGRATING.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
2.0.0 was designed to be an extension of vis-network instead of a wrapper, that's means that all custom-made properties
44
are now the vis-network name
55

6+
7+
Also any snake_case parameters are now camelCase
8+
69
## quick migration
710
```ts
811
oldConfig = {
@@ -17,6 +20,27 @@ const newConfig = migrateFromOldConfig(oldConfig)
1720

1821
## specifics
1922

23+
- any snake_case parameter is now camelCase
24+
25+
```ts
26+
// before
27+
const config = {
28+
container_id: "divId",
29+
initial_cypher: "MATCH (a) RETURN a",
30+
server_database: "neo4j",
31+
console_debug: true
32+
// ...
33+
}
34+
//after
35+
const config = {
36+
containerId: "divId",
37+
initialCypher: "MATCH (a) RETURN a",
38+
serverDatabase: "neo4j",
39+
consoleDebug: true
40+
// ...
41+
}
42+
```
43+
2044
- neo4j driver configuration moved from flat onto the config object to `neo4j` onto the object
2145

2246
```ts
@@ -34,9 +58,9 @@ const config = {
3458
const config = {
3559
// ...
3660
neo4j: { // this can also be a Neo4J driver instance now instead of object
37-
server_url: 'bolt://localhost:7687',
38-
server_user: 'neo4j',
39-
server_password: 'gland-presentation-worry',
61+
serverUrl: 'bolt://localhost:7687',
62+
serverUser: 'neo4j',
63+
serverPassword: 'gland-presentation-worry',
4064
driverConfig: { // full driver config object by neo4j https://neo4j.com/docs/api/javascript-driver/current/function/index.html#configuration
4165
encrypted: "ENCRYPTION_ON",
4266
trust: "TRUST_SYSTEM_CA_SIGNED_CERTIFICATES"

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ And define our draw() function:
152152
153153
function draw() {
154154
const config = {
155-
container_id: "viz",
155+
containerId: "viz",
156156
neo4j: {
157-
server_url: "bolt://localhost:7687",
158-
server_user: "neo4j",
159-
server_password: "sorts-swims-burglaries",
157+
serverUrl: "bolt://localhost:7687",
158+
serverUser: "neo4j",
159+
serverPassword: "sorts-swims-burglaries",
160160
}
161161
labels: {
162162
Character: {
@@ -178,7 +178,7 @@ And define our draw() function:
178178
value: "weight"
179179
}
180180
},
181-
initial_cypher: "MATCH (n)-[r:INTERACTS]->(m) RETURN *"
181+
initialCypher: "MATCH (n)-[r:INTERACTS]->(m) RETURN *"
182182
};
183183
184184
neoViz = new NeoVis.default(config);

__tests__/neovis.tests.ts

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ const Neo4jMock = Neo4jMockImport as unknown as typeof Neo4jMockType;
2222

2323

2424
describe('Neovis', () => {
25-
const container_id = 'randomId';
26-
const initial_cypher = 'test query';
25+
const containerId = 'randomId';
26+
const initialCypher = 'test query';
2727
const label1 = 'label1';
2828
const label2 = 'label2';
2929
const relationshipType = 'TEST';
@@ -32,7 +32,7 @@ describe('Neovis', () => {
3232
beforeEach(() => Neo4jMock.clearAllMocks());
3333
beforeEach(() => {
3434
testUtils.clearIdCounter();
35-
document.body.innerHTML = `<div id="${container_id}"></div>`;
35+
document.body.innerHTML = `<div id="${containerId}"></div>`;
3636
});
3737

3838
describe('NeoVis config defaults behavior', () => {
@@ -123,12 +123,12 @@ describe('Neovis', () => {
123123

124124
describe('Neovis default behavior', () => {
125125
beforeEach(() => {
126-
neovis = new Neovis({ initial_cypher, container_id });
126+
neovis = new Neovis({ initialCypher, containerId });
127127
});
128128

129129
it('should call run with query', () => {
130130
neovis.render();
131-
expect(Neo4jMock.mockSessionRun).toHaveBeenCalledWith(initial_cypher, { limit: 30 });
131+
expect(Neo4jMock.mockSessionRun).toHaveBeenCalledWith(initialCypher, { limit: 30 });
132132
});
133133

134134
it('should call completed when complete', () => new Promise<void>(done => {
@@ -215,8 +215,8 @@ describe('Neovis', () => {
215215
describe('neovis with sizeCypher', () => {
216216
const sizeCypher = 'sizeCypher';
217217
const neovisConfig = {
218-
initial_cypher,
219-
container_id,
218+
initialCypher,
219+
containerId,
220220
labels: {
221221
[label1]: {
222222
[NEOVIS_ADVANCED_CONFIG]: {
@@ -234,7 +234,7 @@ describe('Neovis', () => {
234234
it('should call sizeCypher and save return value to data set value', async () => {
235235
const node = testUtils.makeNode([label1]);
236236
testUtils.mockFullRunSubscribe({
237-
[initial_cypher]: {
237+
[initialCypher]: {
238238
default: [testUtils.makeRecord([node])]
239239
},
240240
[sizeCypher]: {
@@ -252,14 +252,14 @@ describe('Neovis', () => {
252252
describe('neovis with update cypher', () => {
253253
const updateWithCypher = 'updateCypher';
254254
beforeEach(() => {
255-
neovis = new Neovis({ initial_cypher, container_id });
255+
neovis = new Neovis({ initialCypher, containerId });
256256
});
257257

258258
it('should call updateWithCypher and add the new node to visualization', async () => {
259259
const node1 = testUtils.makeNode([label1]);
260260
const node2 = testUtils.makeNode([label1]);
261261
testUtils.mockFullRunSubscribe({
262-
[initial_cypher]: {
262+
[initialCypher]: {
263263
default: [testUtils.makeRecord([node1])]
264264
},
265265
[updateWithCypher]: {
@@ -280,7 +280,7 @@ describe('Neovis', () => {
280280
it('call updateWithCypher with same init query should not create duplicate nodes', async () => {
281281
const node1 = testUtils.makeNode([label1]);
282282
testUtils.mockFullRunSubscribe({
283-
[initial_cypher]: {
283+
[initialCypher]: {
284284
default: [testUtils.makeRecord([node1])]
285285
}
286286
});
@@ -289,7 +289,7 @@ describe('Neovis', () => {
289289
await testUtils.neovisRenderDonePromise(neovis);
290290
expect(Neo4jMock.mockSessionRun).toHaveBeenCalledTimes(1);
291291
expect(neovis.nodes.length).toBe(1); // 1 node before update with cypher
292-
neovis.updateWithCypher(initial_cypher); // do the update
292+
neovis.updateWithCypher(initialCypher); // do the update
293293
await testUtils.neovisRenderDonePromise(neovis);
294294
expect(Neo4jMock.mockSessionRun).toHaveBeenCalledTimes(1 + 1); // once for initial cypher and once for the update
295295
expect(neovis.nodes.length).toBe(1); // 1 node after update with cypher
@@ -300,7 +300,7 @@ describe('Neovis', () => {
300300
const fontSize = 28;
301301
const fontColor = '#00FF00';
302302
describe.each([['config', {
303-
container_id,
303+
containerId,
304304
labels: {
305305
[label1]: {
306306
[NEOVIS_ADVANCED_CONFIG]: {
@@ -314,9 +314,9 @@ describe('Neovis', () => {
314314
}
315315
}
316316
},
317-
initial_cypher: initial_cypher
317+
initialCypher
318318
} as Partial<NeovisConfig>], ['non flat config', {
319-
container_id,
319+
containerId,
320320
nonFlat: true,
321321
labels: {
322322
[label1]: {
@@ -329,7 +329,7 @@ describe('Neovis', () => {
329329
}
330330
}
331331
},
332-
initial_cypher: initial_cypher
332+
initialCypher
333333
} as Partial<NonFlatNeovisConfig>]])('neovis advance %s test', (configName: string, config) => {
334334
beforeEach(() => {
335335
neovis = new Neovis(config as NonFlatNeovisConfig | NeovisConfig);
@@ -338,7 +338,7 @@ describe('Neovis', () => {
338338
it('image field in config should reflect in node data', async () => {
339339
const node1 = testUtils.makeNode([label1]);
340340
testUtils.mockFullRunSubscribe({
341-
[initial_cypher]: {
341+
[initialCypher]: {
342342
default: [testUtils.makeRecord([node1])]
343343
}
344344
});
@@ -351,7 +351,7 @@ describe('Neovis', () => {
351351
it('image field for type not specified in config should not reflect in node data', async () => {
352352
const node1 = testUtils.makeNode([label2]);
353353
testUtils.mockFullRunSubscribe({
354-
[initial_cypher]: {
354+
[initialCypher]: {
355355
default: [testUtils.makeRecord([node1])]
356356
}
357357
});
@@ -364,7 +364,7 @@ describe('Neovis', () => {
364364
it('font field in config should reflect in node data', async () => {
365365
const node1 = testUtils.makeNode([label1]);
366366
testUtils.mockFullRunSubscribe({
367-
[initial_cypher]: {
367+
[initialCypher]: {
368368
default: [testUtils.makeRecord([node1])]
369369
}
370370
});
@@ -379,7 +379,7 @@ describe('Neovis', () => {
379379
it('font field for type not specified in config should not reflect in node data', async () => {
380380
const node1 = testUtils.makeNode([label2]);
381381
testUtils.mockFullRunSubscribe({
382-
[initial_cypher]: {
382+
[initialCypher]: {
383383
default: [testUtils.makeRecord([node1])]
384384
}
385385
});
@@ -398,7 +398,7 @@ describe('Neovis', () => {
398398

399399
it('should merge property name type to vis.js config properly', async () => {
400400
const config: NeovisConfig = {
401-
container_id: container_id,
401+
containerId,
402402
labels: {
403403
[label1]: {
404404
font: {
@@ -407,12 +407,12 @@ describe('Neovis', () => {
407407
},
408408
}
409409
},
410-
initial_cypher: initial_cypher
410+
initialCypher
411411
};
412412
neovis = new Neovis(config);
413413
const node1 = testUtils.makeNode([label1], { [intProperty]: intPropertyValue });
414414
testUtils.mockFullRunSubscribe({
415-
[initial_cypher]: {
415+
[initialCypher]: {
416416
default: [testUtils.makeRecord([node1])]
417417
}
418418
});
@@ -426,7 +426,7 @@ describe('Neovis', () => {
426426

427427
it('should merge static type to vis.js config properly', async () => {
428428
const config: Partial<NeovisConfig> = {
429-
container_id,
429+
containerId,
430430
labels: {
431431
[label1]: {
432432
[NEOVIS_ADVANCED_CONFIG]: {
@@ -436,12 +436,12 @@ describe('Neovis', () => {
436436
}
437437
}
438438
},
439-
initial_cypher
439+
initialCypher
440440
};
441441
neovis = new Neovis(config as NeovisConfig);
442442
const node1 = testUtils.makeNode([label1], { [intProperty]: intPropertyValue });
443443
testUtils.mockFullRunSubscribe({
444-
[initial_cypher]: {
444+
[initialCypher]: {
445445
default: [testUtils.makeRecord([node1])]
446446
}
447447
});
@@ -453,7 +453,7 @@ describe('Neovis', () => {
453453

454454
it('should merge function type to vis.js config properly', async () => {
455455
const config: Partial<NeovisConfig> = {
456-
container_id: container_id,
456+
containerId,
457457
labels: {
458458
[label1]: {
459459
[NEOVIS_ADVANCED_CONFIG]: {
@@ -463,12 +463,12 @@ describe('Neovis', () => {
463463
}
464464
}
465465
},
466-
initial_cypher: initial_cypher
466+
initialCypher
467467
};
468468
neovis = new Neovis(config as NeovisConfig);
469469
const node1 = testUtils.makeNode([label1], { [intProperty]: intPropertyValue });
470470
testUtils.mockFullRunSubscribe({
471-
[initial_cypher]: {
471+
[initialCypher]: {
472472
default: [testUtils.makeRecord([node1])]
473473
}
474474
});
@@ -481,7 +481,7 @@ describe('Neovis', () => {
481481
it('should merge cypher type to vis.js config properly', async () => {
482482
const sizeCypher = 'sizeCypher';
483483
const config: Partial<NeovisConfig> = {
484-
container_id,
484+
containerId,
485485
labels: {
486486
[label1]: {
487487
[NEOVIS_ADVANCED_CONFIG]: {
@@ -491,12 +491,12 @@ describe('Neovis', () => {
491491
}
492492
}
493493
},
494-
initial_cypher: initial_cypher
494+
initialCypher
495495
};
496496
neovis = new Neovis(config as NeovisConfig);
497497
const node1 = testUtils.makeNode([label1], { [intProperty]: intPropertyValue });
498498
testUtils.mockFullRunSubscribe({
499-
[initial_cypher]: {
499+
[initialCypher]: {
500500
default: [testUtils.makeRecord([node1])]
501501
},
502502
[sizeCypher]: {
@@ -513,8 +513,8 @@ describe('Neovis', () => {
513513

514514
describe('neovis config migration', () => {
515515
const oldConfig: Partial<OldNeoVisConfig> = {
516-
initial_cypher,
517-
container_id,
516+
initial_cypher: initialCypher,
517+
container_id: containerId,
518518
labels: {
519519
a: {
520520
caption: 'name'

examples/advanced-example.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535

3636
function draw() {
3737
var config = {
38-
container_id: 'viz',
38+
containerId: 'viz',
3939
neo4j: {
40-
server_url: 'bolt://localhost:7687',
41-
server_user: 'neo4j',
42-
server_password: 'gland-presentation-worry'
40+
serverUrl: 'bolt://localhost:7687',
41+
serverUser: 'neo4j',
42+
serverPassword: 'gland-presentation-worry'
4343
},
4444
visConfig: {
4545
nodes: {
@@ -75,7 +75,7 @@
7575
}
7676
}
7777
},
78-
initial_cypher: 'MATCH (n)-[r]->(m) RETURN n,r,m'
78+
initialCypher: 'MATCH (n)-[r]->(m) RETURN n,r,m'
7979
};
8080

8181
viz = new NeoVis.default(config);

examples/example-labels.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434

3535
function draw() {
3636
var config = {
37-
container_id: "viz",
37+
containerId: "viz",
3838
neo4j: {
39-
server_url: "bolt://54.209.44.254:33146",
40-
server_user: "neo4j",
41-
server_password: "investigators-spill-future"
39+
serverUrl: "bolt://54.209.44.254:33146",
40+
serverUser: "neo4j",
41+
serverPassword: "investigators-spill-future"
4242
},
4343
labels: {
4444
//"Character": "name",
@@ -71,7 +71,7 @@
7171
label: "El Presidente"
7272
}
7373
},
74-
initial_cypher: "match (p:Person)-[r]-(o:Organization)-[r1]-(p2:Person) RETURN * LIMIT 10"
74+
initialCypher: "match (p:Person)-[r]-(o:Organization)-[r1]-(p2:Person) RETURN * LIMIT 10"
7575
};
7676

7777
viz = new NeoVis.default(config);

0 commit comments

Comments
 (0)