Skip to content

Commit

Permalink
Add removeAllTests method
Browse files Browse the repository at this point in the history
Like removeTest but more wumbo
  • Loading branch information
pineapplemachine committed Mar 28, 2018
1 parent 54ac8c2 commit 3adffbd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions canary.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,11 +690,20 @@ class CanaryTest{
this.logVerbose(`Removing child test "${child.name}" from parent test "${this.name}".`);
const index = this.children.indexOf(child);
if(index >= 0){
this.children[index].parent = undefined;
this.children.splice(index, 1);
return true;
}
return false;
}
// Remove all child tests.
removeAllTests(){
this.logVerbose(`Removing all child tests from "${this.name}".`);
for(let child of this.children){
child.parent = undefined;
}
this.children = [];
}
// Add a Test instance as a child of this one.
addTest(child){
this.logVerbose(`Adding a child test "${child.name}" to parent "${this.name}".`);
Expand Down
6 changes: 6 additions & 0 deletions docs/api-advanced-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ Remove a child test from a parent group.

**Returns:** `true` if the test was in fact a child and was removed and `false` if it was not.

# removeAllTests

Remove all child tests from a parent group.

**Arguments:** `({CanaryTest} test)`

# orphan

Remove a test from its parent group.
Expand Down

0 comments on commit 3adffbd

Please sign in to comment.