Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/dot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ describe('dot.DotGraph.toString()', () => {
expect(screen.getByTestId('dot-src').textContent).toBe(dotSrc);
});

it('accepts "c" as a compass point on nodes', () => {
let dotSrc = 'digraph {a:p1:c}';
render(<WrapDot dotSrc={dotSrc} />);
expect(screen.getByTestId('dot-src').textContent).toBe(dotSrc);
});

it('renders nodes with names equal to properties of the Javascript Object', () => {
const nodeNames = getAllPropertyNames({});
const dotSrc = `digraph {${nodeNames.join(' ')}}`;
Expand Down Expand Up @@ -286,6 +292,12 @@ describe('dot.DotGraph.toString()', () => {
expect(screen.getByTestId('dot-src').textContent).toBe(dotSrc);
});

it('renders an edge directed at the center point of two nodes', () => {
let dotSrc = 'digraph {a:p1:c -> b:p2:c}';
render(<WrapDot dotSrc={dotSrc} />);
expect(screen.getByTestId('dot-src').textContent).toBe(dotSrc);
});

// nodes and edges

it('renders multiple nodes and edges', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/dotGrammar.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ subgraph
}

compass_pt
= 'n'/'ne'/'e'/'se'/'s'/'sw'/'w'/'nw'
= 'n'/'ne'/'e'/'se'/'s'/'sw'/'w'/'nw'/'c'

ID
= STRING
Expand Down