Skip to content

Commit

Permalink
Add @josejulio's second test case, re: When using cy.json, sometime…
Browse files Browse the repository at this point in the history
…s some nodes are not being deleted #2231
  • Loading branch information
maxkfranz committed Dec 7, 2018
1 parent 216b5fa commit 9c8ef21
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion test/core-graph-manipulation.js
Expand Up @@ -454,7 +454,7 @@ describe('Core graph manipulation', function(){
it('cy.json() can remove all elements', function() {
// Issue #2231
var cb = 0;
cy.on('remove', function() { cb++ });
cy.on('remove', function() { cb++; });

cy.json({
elements: {
Expand All @@ -472,6 +472,28 @@ describe('Core graph manipulation', function(){
expect( cb ).to.equal(5); // 3 nodes and 2 edges
});

it('cy.json() removes all but last element', function(){
// clean up before test:
cy.elements().remove();
cy.add([
{ data: { id: 'a' } },
{ data: { id: 'b' } },
{ data: { id: 'c' } },
{ data: { id: 'd' } }
]);

cy.json({
elements: [
{ data: { id: 'd' } }
]
});

expect( cy.$('#a').empty(), 'node a not in graph' ).to.be.true;
expect( cy.$('#b').empty(), 'node b not in graph' ).to.be.true;
expect( cy.$('#c').empty(), 'node c not in graph' ).to.be.true;
expect( cy.$('#d').nonempty(), 'node d in graph' ).to.be.true;
});

it('cy.json() removes parent', function(){
// clean up before test:
cy.elements().remove();
Expand Down

0 comments on commit 9c8ef21

Please sign in to comment.