-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Expand file tree
/
Copy pathtest_wordsearch.js
More file actions
104 lines (91 loc) · 3.29 KB
/
test_wordsearch.js
File metadata and controls
104 lines (91 loc) · 3.29 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const chai = require("chai");
const assert = chai.assert;
const wordSearch = require("../wordsearch.js");
describe("#wordSearch()", function () {
it("should return false if the word is not present", function () {
const result = wordSearch(
[
["A", "W", "C", "F", "Q", "U", "A", "L"],
["S", "E", "I", "N", "F", "E", "L", "D"],
["Y", "F", "C", "F", "Q", "U", "A", "L"],
["H", "M", "J", "T", "E", "V", "R", "G"],
["W", "H", "C", "S", "Y", "E", "R", "L"],
["B", "F", "R", "E", "N", "E", "Y", "B"],
["U", "B", "T", "W", "A", "P", "A", "I"],
["O", "D", "C", "A", "K", "U", "A", "S"],
["E", "Z", "K", "F", "Q", "U", "A", "L"],
],
"FRANK"
);
assert.isFalse(result);
});
it("should return true if the word is present horizpntal search", function () {
const result = wordSearch(
[
["A", "W", "C", "F", "Q", "U", "A", "L"],
["S", "E", "I", "N", "F", "E", "L", "D"],
["Y", "F", "C", "F", "Q", "U", "A", "L"],
["H", "M", "J", "T", "E", "V", "R", "G"],
["W", "H", "C", "S", "Y", "E", "R", "L"],
["B", "F", "R", "E", "N", "E", "Y", "B"],
["U", "B", "T", "W", "A", "P", "A", "I"],
["O", "D", "C", "A", "K", "U", "A", "S"],
["E", "Z", "K", "F", "Q", "U", "A", "L"],
],
"SEINFELD"
);
assert.isTrue(result);
});
it("should return true if the word is present vertical search", function () {
const result = wordSearch(
[
["A", "W", "C", "F", "Q", "U", "A", "L"],
["S", "E", "I", "N", "F", "E", "L", "D"],
["Y", "F", "C", "F", "Q", "U", "A", "L"],
["H", "M", "J", "T", "E", "B", "R", "G"],
["W", "H", "C", "S", "Y", "A", "R", "L"],
["B", "F", "R", "E", "N", "N", "Y", "B"],
["U", "B", "T", "W", "A", "K", "A", "I"],
["O", "D", "C", "A", "K", "U", "A", "S"],
["E", "Z", "K", "F", "Q", "U", "A", "L"],
],
"BANK"
);
assert.isTrue(result);
});
it("should return false if no word is added", function () {
const result = wordSearch(
[
["A", "W", "C", "F", "Q", "U", "A", "L"],
["S", "E", "I", "N", "F", "E", "L", "D"],
["Y", "F", "C", "F", "Q", "U", "A", "L"],
["H", "M", "J", "T", "E", "B", "R", "G"],
["W", "H", "C", "S", "Y", "A", "R", "L"],
["B", "F", "R", "E", "N", "N", "Y", "B"],
["U", "B", "T", "W", "A", "K", "A", "I"],
["O", "D", "C", "A", "K", "U", "A", "S"],
["E", "Z", "K", "F", "Q", "U", "A", "L"],
],
""
);
assert.isFalse(result);
});
it("should return false if there is no array ", function () {
const result = wordSearch("", "BANK");
assert.isFalse(result);
});
it("should return false if no word is added", function () {
const result = wordSearch([
["A", "W", "C", "F", "Q", "U", "A", "L"],
["S", "E", "I", "N", "F", "E", "L", "D"],
["Y", "F", "C", "F", "Q", "U", "A", "L"],
["H", "M", "J", "T", "E", "B", "R", "G"],
["W", "H", "C", "S", "Y", "A", "R", "L"],
["B", "F", "R", "E", "N", "N", "Y", "B"],
["U", "B", "T", "W", "A", "K", "A", "I"],
["O", "D", "C", "A", "K", "U", "A", "S"],
["E", "Z", "K", "F", "Q", "U", "A", "L"],
]);
assert.isFalse(result);
});
});