Skip to content

Commit e055948

Browse files
Added skips
1 parent 8a4c14e commit e055948

1 file changed

Lines changed: 67 additions & 67 deletions

File tree

Tries/test.js

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,87 @@
1-
const { Trie, TrieNode } = require('./index');
1+
const { Trie, TrieNode } = require("./index");
22

33
let isEndOfWord, children;
44
let _root;
55

6-
describe('TrieNode and Trie', () => {
7-
test('TrieNode hold two properties, a boolean value for end of word and another for children', () => {
8-
const node = new TrieNode();
9-
const keys = Object.keys(node);
10-
const valuesTypeOf = Object.values(node).map((v) => typeof v);
6+
describe("TrieNode and Trie", () => {
7+
test("TrieNode hold two properties, a boolean value for end of word and another for children", () => {
8+
const node = new TrieNode();
9+
const keys = Object.keys(node);
10+
const valuesTypeOf = Object.values(node).map(v => typeof v);
1111

12-
expect(keys.length).toEqual(2);
13-
expect(valuesTypeOf.includes('boolean')).toEqual(true);
14-
expect(valuesTypeOf.includes('object')).toEqual(true);
12+
expect(keys.length).toEqual(2);
13+
expect(valuesTypeOf.includes("boolean")).toEqual(true);
14+
expect(valuesTypeOf.includes("object")).toEqual(true);
1515

16-
//Get name of properties on TrieNode
17-
for (key in node) {
18-
if (typeof node[key] === 'boolean') {
19-
isEndOfWord = key;
20-
}
21-
if (typeof node[key] === 'object') {
22-
children = key;
23-
}
24-
}
25-
});
26-
test('Trie has single property holding root, root must be Trie Node.', () => {
27-
const trie = new Trie();
28-
const keys = Object.keys(trie);
29-
expect(keys.length).toEqual(1);
30-
_root = keys[0];
31-
expect(trie[_root] instanceof TrieNode).toEqual(true);
32-
});
16+
//Get name of properties on TrieNode
17+
for (key in node) {
18+
if (typeof node[key] === "boolean") {
19+
isEndOfWord = key;
20+
}
21+
if (typeof node[key] === "object") {
22+
children = key;
23+
}
24+
}
25+
});
26+
test("Trie has single property holding root, root must be Trie Node.", () => {
27+
const trie = new Trie();
28+
const keys = Object.keys(trie);
29+
expect(keys.length).toEqual(1);
30+
_root = keys[0];
31+
expect(trie[_root] instanceof TrieNode).toEqual(true);
32+
});
3333
});
3434

35-
describe('insert', () => {
36-
test('inserts nodes and marks correct node as end of word.', () => {
37-
const t = new Trie();
38-
t.insert('man');
39-
t.insert('mat');
35+
describe.skip("insert", () => {
36+
test("inserts nodes and marks correct node as end of word.", () => {
37+
const t = new Trie();
38+
t.insert("man");
39+
t.insert("mat");
4040

41-
const rootNode = t[_root];
42-
expect(rootNode[isEndOfWord]).toEqual(false);
43-
//Check that root only has one child of "m"
44-
expect(Object.keys(rootNode[children]).length).toEqual(1);
41+
const rootNode = t[_root];
42+
expect(rootNode[isEndOfWord]).toEqual(false);
43+
//Check that root only has one child of "m"
44+
expect(Object.keys(rootNode[children]).length).toEqual(1);
4545

46-
const mNode = rootNode[children]['m'];
47-
expect(Object.keys(mNode[children]).length).toEqual(1);
46+
const mNode = rootNode[children]["m"];
47+
expect(Object.keys(mNode[children]).length).toEqual(1);
4848

49-
const aNode = mNode[children]['a'];
50-
expect(aNode[isEndOfWord]).toEqual(false);
51-
expect(Object.keys(aNode[children]).length).toEqual(2);
49+
const aNode = mNode[children]["a"];
50+
expect(aNode[isEndOfWord]).toEqual(false);
51+
expect(Object.keys(aNode[children]).length).toEqual(2);
5252

53-
const tNode = aNode[children]['t'];
54-
const nNode = aNode[children]['n'];
55-
expect(tNode[isEndOfWord]).toEqual(true);
56-
expect(nNode[isEndOfWord]).toEqual(true);
57-
});
53+
const tNode = aNode[children]["t"];
54+
const nNode = aNode[children]["n"];
55+
expect(tNode[isEndOfWord]).toEqual(true);
56+
expect(nNode[isEndOfWord]).toEqual(true);
57+
});
5858
});
5959

60-
describe('search', () => {
61-
const t = new Trie();
62-
t.insert('canada');
60+
describe.skip("search", () => {
61+
const t = new Trie();
62+
t.insert("canada");
6363

64-
test('returns true if word found', () => {
65-
expect(t.search('canada')).toEqual(true);
66-
});
67-
test('returns false if word not found', () => {
68-
expect(t.search('a')).toEqual(false);
69-
expect(t.search('canad')).toEqual(false);
70-
});
64+
test("returns true if word found", () => {
65+
expect(t.search("canada")).toEqual(true);
66+
});
67+
test("returns false if word not found", () => {
68+
expect(t.search("a")).toEqual(false);
69+
expect(t.search("canad")).toEqual(false);
70+
});
7171
});
7272

73-
describe('Prefix', () => {
74-
test('autocomplete(prefix) works', () => {
75-
const t = new Trie();
76-
t.insert('carer');
77-
t.insert('care');
78-
t.insert('card');
79-
t.insert('car');
73+
describe.skip("Prefix", () => {
74+
test("autocomplete(prefix) works", () => {
75+
const t = new Trie();
76+
t.insert("carer");
77+
t.insert("care");
78+
t.insert("card");
79+
t.insert("car");
8080

81-
expect(t.autocomplete('care').length).toEqual(2);
82-
expect(t.autocomplete('car').length).toEqual(4);
81+
expect(t.autocomplete("care").length).toEqual(2);
82+
expect(t.autocomplete("car").length).toEqual(4);
8383

84-
expect(t.autocomplete('card')).toEqual([ 'card' ]);
85-
expect(t.autocomplete('meow')).toEqual([]);
86-
});
84+
expect(t.autocomplete("card")).toEqual(["card"]);
85+
expect(t.autocomplete("meow")).toEqual([]);
86+
});
8787
});

0 commit comments

Comments
 (0)