All files / trees BPlusTreeWebAD.test.js

0% Statements 0/31
100% Branches 0/0
0% Functions 0/4
0% Lines 0/28

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39                                                                             
import * as d3 from 'd3';
import BPlusTree from './BPlusWebAD1';
 
describe('BPlusTree.js', () => {
  it('Print a B+Tree', () => {
    const tree = new BPlusTree(1);
    const arr = [1, 2, 3, 4, 5, 6, 7];
    for (let i = 0; i < arr.length; ++i) {
      tree.addFixed(arr[i]);
      console.log(i);
      tree.print();
    }
    tree.print(tree.root, 0);
    console.log('AFTER DELETE');
    tree.remove(5);
    tree.remove(1);
    tree.print(tree.root, 0);
  });
 
  it('Test d3 Hierachy working with WEBAD Tree', () => {
    const tree = new BPlusTree(1);
    const arr = [1, 2, 3, 4, 5, 6, 7];
    for (let i = 0; i < arr.length; ++i) {
      tree.addFixed(arr[i]);
      console.log(i);
      tree.print();
    }
    tree.print(tree.root, 0);
    console.log('AFTER DELETE');
    tree.remove(5);
    const hierarchy = d3.hierarchy(tree.root, (d) => d.pointers);
    const treeLayout = d3.tree()
      .size([1000, 300]);
    console.log(hierarchy === undefined);
    const btree = treeLayout(hierarchy);
    console.log(btree.descendants());
  });
});