This repository was archived by the owner on Jun 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript-test.js
More file actions
63 lines (52 loc) · 1.57 KB
/
script-test.js
File metadata and controls
63 lines (52 loc) · 1.57 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
describe("search(str)", () => {
it("should return an array of fruits that contain the String argument", () => {
expect(
search("ppl")
).toEqual(["Apple 🍎", "Custard apple", "Pineapple 🍍"]);
expect(
search("wat")
).toEqual(["Watermelon 🍉"]);
});
it("should return fruits regardless of case", () => {
expect(
search("CHEE")
).toEqual(["Lychee"]);
expect(
search("pomelo")
).toEqual(["Pomelo"]);
});
it("should recognize emojis as a search", () => {
expect(
search("🍉")
).toEqual(["Watermelon 🍉"]);
});
it("should return an empty array for an unrecognized fruit", () => {
expect(
search("abcd")
).toEqual([]);
});
});
describe("separateStringForBolding(str, substr)", () => {
it("should return an array containing the piece of substring, before the substring, and after the substring", () => {
expect(
separateStringForBolding("Apple 🍎", "pp")
).toEqual(["A", "pp", "le 🍎"]);
expect(
separateStringForBolding("Raspberry", "Rasp")
).toEqual(["", "Rasp", "berry"]);
expect(
separateStringForBolding("Raspberry", "berry")
).toEqual(["Rasp", "berry", ""]);
});
it("should return an array of the pieces regardless of case", () => {
expect(
separateStringForBolding("Melon 🍈", "LON")
).toEqual(["Me", "lon", " 🍈"]);
expect(
separateStringForBolding("Honeydew", "honey")
).toEqual(["", "Honey", "dew"]);
expect(
separateStringForBolding("ABCED", "bc")
).toEqual(["A", "BC", "ED"]);
});
});