Skip to content

Commit

Permalink
[REFACTOR] New object comparing fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gonzalo Diaz committed Apr 9, 2024
1 parent db7ab37 commit c5cb50d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/projecteuler/lib/BNodeBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ describe('class BNodeBuilder for binary trees', () => {
expect.assertions(1);

const tree = BNodeBuilder.buildBNodeTree(data, 0, 0);
const treeStringify = JSON.stringify(tree);

const comparedTree = new BNode(75, new BNode(95), new BNode(64));
const comparedTreeStringify = JSON.stringify(comparedTree);

expect(tree).toMatchObject(comparedTree);
expect(treeStringify).toBe(comparedTreeStringify);
});

it('tree of BNode: building tree with invalid coordinates', () => {
Expand All @@ -46,15 +48,19 @@ describe('class BNodeBuilder for binary weight trees', () => {

// with default value for rootValue = 0
let tree = BNodeBuilder.buildBNodeTreeWeight(data, 0, 0);
const treeStringify = JSON.stringify(tree);
let comparedTree = new BNode(75, new BNode(170), new BNode(139));
const comparedTreeStringify = JSON.stringify(comparedTree);

expect(tree).toMatchObject(comparedTree);
expect(treeStringify).toBe(comparedTreeStringify);

// with rootValue = null
tree = BNodeBuilder.buildBNodeTreeWeight(data, 0, 0, null);
const treeStringify2 = JSON.stringify(tree);
comparedTree = new BNode(75, new BNode(170), new BNode(139));
const comparedTreeStringify2 = JSON.stringify(comparedTree);

expect(tree).toMatchObject(comparedTree);
expect(treeStringify2).toBe(comparedTreeStringify2);
});

it('tree of BNode: building Weight tree with invalid coordinates', () => {
Expand Down

0 comments on commit c5cb50d

Please sign in to comment.