Skip to content

Commit

Permalink
feat(text): remove multiple nodes as valid graph
Browse files Browse the repository at this point in the history
  • Loading branch information
davidballester committed Aug 8, 2019
1 parent a750d11 commit 1fbf9c9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 74 deletions.
6 changes: 3 additions & 3 deletions src/services/graph-grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Grapher {
path
= partialPath+ node --partials
| node+ --nodes
| node --node
partialPath = node link
Expand Down Expand Up @@ -82,8 +82,8 @@ class GraphGrammar {
groups: groups.map(mapGroup).filter((item, index, groups) => groups.findIndex((candidate) => candidate.name === item.name) === index),
};
},
path_nodes: (nodes) => {
const entities = _flattenDeep(nodes.eval());
path_node: (node) => {
const entities = node.eval();
return {
nodes: entities.filter(({ type }) => type === 'node').map(mapNode),
groups: entities
Expand Down
71 changes: 0 additions & 71 deletions src/services/graph-grammar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ describe('graph-grammar', () => {
expect(matchResult.succeeded()).toBeTruthy();
});

it('matches multiple nodes', () => {
const matchResult = graphGrammar.match('(foo)(bar)(baz)');
expect(matchResult.succeeded()).toBeTruthy();
});

it('matches simple paths', () => {
const matchResult = graphGrammar.match('(foo)->(bar)');
expect(matchResult.succeeded()).toBeTruthy();
Expand Down Expand Up @@ -106,24 +101,6 @@ describe('graph-grammar', () => {
});
});

it('turns multiple nodes into an object with a multiple nodes', () => {
const result = graphGrammar.eval(graphGrammar.match('(foo)(bar)(baz)'));
expect(result).toEqual({
nodes: [
{
id: 'foo',
},
{
id: 'bar',
},
{
id: 'baz',
},
],
groups: [],
});
});

it('creates a link with the specified label', () => {
const result = graphGrammar.eval(graphGrammar.match('(foo)-[baz]->(bar)'));
expect(result.links).toEqual([
Expand Down Expand Up @@ -275,54 +252,6 @@ describe('graph-grammar', () => {
});
});

it('turns two nodes with repeated groups into a node and non-repeated groups', () => {
const result = graphGrammar.eval(graphGrammar.match('(foo:bar:baz)(qux:bar:quux)'));
expect(result).toEqual({
nodes: [
{
id: 'foo',
groups: [
{
id: expect.anything(),
name: 'bar',
},
{
id: expect.anything(),
name: 'baz',
},
],
},
{
id: 'qux',
groups: [
{
id: expect.anything(),
name: 'bar',
},
{
id: expect.anything(),
name: 'quux',
},
],
},
],
groups: [
{
id: expect.anything(),
name: 'bar',
},
{
id: expect.anything(),
name: 'baz',
},
{
id: expect.anything(),
name: 'quux',
},
],
});
});

it('turns a simple path with groups into those nodes, link and groups', () => {
const result = graphGrammar.eval(graphGrammar.match('(foo)-[:qux]->(bar)'));
expect(result).toEqual({
Expand Down

0 comments on commit 1fbf9c9

Please sign in to comment.