flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
67
BACK_BACK/node_modules/tree/test/branch.js
generated
vendored
Executable file
67
BACK_BACK/node_modules/tree/test/branch.js
generated
vendored
Executable file
|
|
@ -0,0 +1,67 @@
|
|||
module('Branch', {
|
||||
|
||||
setup: function() {
|
||||
this.node1 = new Tree.Node();
|
||||
this.node2 = new Tree.Node();
|
||||
this.node3 = new Tree.Node();
|
||||
this.branch = new Tree.Branch([this.node1, this.node2, this.node3]);
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
delete this.node1;
|
||||
delete this.node2;
|
||||
delete this.node3;
|
||||
delete this.branch;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
test('size', function() {
|
||||
equals(this.branch.size(), 3);
|
||||
});
|
||||
|
||||
test('append node', function() {
|
||||
var node = new Tree.Node({}, []);
|
||||
this.branch.append(node);
|
||||
|
||||
equals(this.branch.size(), 4);
|
||||
equals(_.last(this.branch.nodes), node);
|
||||
equals(node.branch, this.branch);
|
||||
});
|
||||
|
||||
test('insert node', function() {
|
||||
var node = new Tree.Node({}, []);
|
||||
this.branch.insert(2, node);
|
||||
|
||||
equals(this.branch.size(), 4);
|
||||
equals(this.branch.nodes[2], node);
|
||||
equals(node.branch, this.branch);
|
||||
|
||||
node = new Tree.Node({}, []);
|
||||
this.branch.insert(9999, node);
|
||||
|
||||
equals(_.last(this.branch.nodes), node);
|
||||
|
||||
node = new Tree.Node({}, []);
|
||||
this.branch.insert(-1, node);
|
||||
|
||||
equals(_.first(this.branch.nodes), node);
|
||||
});
|
||||
|
||||
test('remove node', function() {
|
||||
var node = this.branch.remove(this.node1);
|
||||
|
||||
equals(this.branch.size(), 2);
|
||||
equals(_.first(this.branch.nodes), this.node2);
|
||||
equals(_.last(this.branch.nodes), this.node3);
|
||||
equals(node, this.node1);
|
||||
equals(node.branch, null);
|
||||
});
|
||||
|
||||
test('remove node at index', function() {
|
||||
this.branch.removeAtIndex(2);
|
||||
|
||||
equals(this.branch.size(), 2);
|
||||
equals(_.first(this.branch.nodes), this.node1);
|
||||
equals(_.last(this.branch.nodes), this.node2);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue