Skip to content

Commit

Permalink
changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
huboneo committed Aug 30, 2019
1 parent 6151edc commit 5bb6808
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 48 deletions.
15 changes: 4 additions & 11 deletions src/browser/modules/Stream/CypherFrame/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
isObjectLike,
lowerCase,
map,
omit,
reduce
} from 'lodash-es'

Expand Down Expand Up @@ -340,18 +339,12 @@ function mapNeo4jValuesToPlainValues (values) {
}

// could be a Node or Relationship
const type = lowerCase(get(values, 'constructor.name', ''))

if (includes(['relationship', 'node'], type)) {
const labels =
type === 'relationship'
? { label: get(values, 'type') }
: { labels: get(values, 'labels', []) }
const elementType = lowerCase(get(values, 'constructor.name', ''))

if (includes(['relationship', 'node'], elementType)) {
return {
type,
...labels,
...mapNeo4jValuesToPlainValues(omit(values, ['type', 'labels']))
elementType,
...mapNeo4jValuesToPlainValues({ ...values })
}
}

Expand Down
74 changes: 37 additions & 37 deletions src/browser/modules/Stream/CypherFrame/helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ describe('helpers', () => {
const expected = {
n: {
identity: 1,
type: 'node',
elementType: 'node',
labels: ['foo'],
properties: {
bar: 3
Expand All @@ -753,7 +753,7 @@ describe('helpers', () => {
const expected = {
n: {
identity: 1,
type: 'node',
elementType: 'node',
labels: ['foo'],
properties: {
bar: 'baz'
Expand All @@ -772,7 +772,7 @@ describe('helpers', () => {
const expected = {
n: {
identity: 1,
type: 'node',
elementType: 'node',
labels: ['foo'],
properties: {
bar: '1970-01-01'
Expand All @@ -791,7 +791,7 @@ describe('helpers', () => {
const expected = {
n: {
identity: 1,
type: 'node',
elementType: 'node',
labels: ['foo'],
properties: {
bar: '11:01:12Z'
Expand All @@ -810,7 +810,7 @@ describe('helpers', () => {
const expected = {
n: {
identity: 1,
type: 'node',
elementType: 'node',
labels: ['foo'],
properties: {
bar: '11:01:12'
Expand All @@ -829,7 +829,7 @@ describe('helpers', () => {
const expected = {
n: {
identity: 1,
type: 'node',
elementType: 'node',
labels: ['foo'],
properties: {
bar: '1970-01-01T11:01:12Z'
Expand All @@ -848,7 +848,7 @@ describe('helpers', () => {
const expected = {
n: {
identity: 1,
type: 'node',
elementType: 'node',
labels: ['foo'],
properties: {
bar: '1970-01-01T11:01:12'
Expand All @@ -867,7 +867,7 @@ describe('helpers', () => {
const expected = {
n: {
identity: 1,
type: 'node',
elementType: 'node',
labels: ['foo'],
properties: {
bar: { srid: 1, x: 10, y: 5, z: 15 }
Expand All @@ -886,7 +886,7 @@ describe('helpers', () => {
const expected = {
n: {
identity: 1,
type: 'node',
elementType: 'node',
labels: ['foo'],
properties: {
bar: 'P10M5DT1S'
Expand All @@ -909,8 +909,8 @@ describe('helpers', () => {
identity: 1,
start: 2,
end: 3,
type: 'relationship',
label: 'foo',
elementType: 'relationship',
type: 'foo',
properties: {
bar: 3
}
Expand All @@ -930,8 +930,8 @@ describe('helpers', () => {
identity: 1,
start: 2,
end: 3,
type: 'relationship',
label: 'foo',
elementType: 'relationship',
type: 'foo',
properties: {
bar: 'baz'
}
Expand All @@ -951,8 +951,8 @@ describe('helpers', () => {
identity: 1,
start: 2,
end: 3,
type: 'relationship',
label: 'foo',
elementType: 'relationship',
type: 'foo',
properties: {
bar: '1970-01-01'
}
Expand All @@ -972,8 +972,8 @@ describe('helpers', () => {
identity: 1,
start: 2,
end: 3,
type: 'relationship',
label: 'foo',
elementType: 'relationship',
type: 'foo',
properties: {
bar: '11:01:12Z'
}
Expand All @@ -993,8 +993,8 @@ describe('helpers', () => {
identity: 1,
start: 2,
end: 3,
type: 'relationship',
label: 'foo',
elementType: 'relationship',
type: 'foo',
properties: {
bar: '11:01:12'
}
Expand All @@ -1014,8 +1014,8 @@ describe('helpers', () => {
identity: 1,
start: 2,
end: 3,
type: 'relationship',
label: 'foo',
elementType: 'relationship',
type: 'foo',
properties: {
bar: '1970-01-01T11:01:12Z'
}
Expand All @@ -1035,8 +1035,8 @@ describe('helpers', () => {
identity: 1,
start: 2,
end: 3,
type: 'relationship',
label: 'foo',
elementType: 'relationship',
type: 'foo',
properties: {
bar: '1970-01-01T11:01:12'
}
Expand All @@ -1056,8 +1056,8 @@ describe('helpers', () => {
identity: 1,
start: 2,
end: 3,
type: 'relationship',
label: 'foo',
elementType: 'relationship',
type: 'foo',
properties: {
bar: { srid: 1, x: 10, y: 5, z: 15 }
}
Expand All @@ -1077,8 +1077,8 @@ describe('helpers', () => {
identity: 1,
start: 2,
end: 3,
type: 'relationship',
label: 'foo',
elementType: 'relationship',
type: 'foo',
properties: {
bar: 'P10M5DT1S'
}
Expand Down Expand Up @@ -1107,16 +1107,16 @@ describe('helpers', () => {
const expected = {
n1: {
identity: 1,
type: 'node',
elementType: 'node',
labels: ['foo'],
properties: {
bar: 3
}
},
r1: {
identity: 3,
type: 'relationship',
label: 'bom',
elementType: 'relationship',
type: 'bom',
start: 1,
end: 2,
properties: {
Expand All @@ -1125,7 +1125,7 @@ describe('helpers', () => {
},
n2: {
identity: 2,
type: 'node',
elementType: 'node',
labels: ['bam'],
properties: {
bar: '1970-01-01'
Expand Down Expand Up @@ -1157,15 +1157,15 @@ describe('helpers', () => {
length: 1,
start: {
identity: 1,
type: 'node',
elementType: 'node',
labels: ['foo'],
properties: {
bar: 3
}
},
end: {
identity: 2,
type: 'node',
elementType: 'node',
labels: ['bam'],
properties: {
bar: '1970-01-01'
Expand All @@ -1175,16 +1175,16 @@ describe('helpers', () => {
{
start: {
identity: 1,
type: 'node',
elementType: 'node',
labels: ['foo'],
properties: {
bar: 3
}
},
relationship: {
identity: 3,
type: 'relationship',
label: 'bom',
elementType: 'relationship',
type: 'bom',
start: 1,
end: 2,
properties: {
Expand All @@ -1193,7 +1193,7 @@ describe('helpers', () => {
},
end: {
identity: 2,
type: 'node',
elementType: 'node',
labels: ['bam'],
properties: {
bar: '1970-01-01'
Expand Down

0 comments on commit 5bb6808

Please sign in to comment.