Skip to content

Commit

Permalink
feat(test): add connect test
Browse files Browse the repository at this point in the history
  • Loading branch information
moklick committed Oct 3, 2019
1 parent 22d2e62 commit 68ec185
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
25 changes: 20 additions & 5 deletions cypress/integration/flow/basic.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ describe('Basic Flow Rendering', () => {
cy.visit('/index.html');

cy.get('.react-graph__renderer');
cy.get('.react-graph__node').should('have.length', 3);
cy.get('.react-graph__node').should('have.length', 4);
cy.get('.react-graph__edge').should('have.length', 2);
});

Expand All @@ -16,7 +16,7 @@ describe('Basic Flow Rendering', () => {
});

it('deselects node', () => {
cy.get('.react-graph__renderer').click(0, 0);
cy.get('.react-graph__renderer').click('bottomRight');
cy.get('.react-graph__node:first').should('not.have.class', 'selected');
});

Expand All @@ -30,7 +30,7 @@ describe('Basic Flow Rendering', () => {
.trigger('mousemove', 'bottomRight', { which: 1 })
.trigger('mouseup', 'bottomRight', { force: true });

cy.get('.react-graph__node').should('have.class', 'selected');
cy.get('.react-graph__node').should('have.class', 'selected');
});

it('selects an edge', () => {
Expand All @@ -48,10 +48,25 @@ describe('Basic Flow Rendering', () => {
});

it('removes a node', () => {
cy.get('.react-graph__node:last').click();
cy.get('.react-graph__node').contains('Node 2').click();
cy.get('body').type('{backspace}');

cy.get('.react-graph__node').should('have.length', 2);
cy.get('.react-graph__node').should('have.length', 3);
cy.get('.react-graph__edge').should('have.length', 1);
});

it('connect nodes', () => {
cy.get('.react-graph__node')
.contains('Node 3')
.find('.react-graph__handle.source')
.trigger('mousedown', { which: 1 });

cy.get('.react-graph__node')
.contains('Node 4')
.find('.react-graph__handle.target')
.trigger('mousemove', { which: 1 })
.trigger('mouseup', { force: true });

cy.get('.react-graph__edge').should('have.length', 2);
})
});
1 change: 1 addition & 0 deletions examples/basic/scripts/ExampleGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class App extends PureComponent {
{ id: '1', type: 'input', data: { label: 'Node 1' }, position: { x: 250, y: 5 } },
{ id: '2', data: { label: 'Node 2' }, position: { x: 100, y: 100 } },
{ id: '3', data: { label: 'Node 3' }, position: { x: 400, y: 100 } },
{ id: '4', data: { label: 'Node 4' }, position: { x: 400, y: 200 } },
{ source: '1', target: '2', animated: true },
{ source: '1', target: '3' },
]
Expand Down

0 comments on commit 68ec185

Please sign in to comment.