Skip to content

Commit f9f7dc0

Browse files
committed
Add comments to includes tests
1 parent 7866c4b commit f9f7dc0

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Sprint-1/refactor/includes.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,49 @@
22

33
const includes = require("./includes.js");
44

5+
// Given an array containing the target value
6+
// When passed to the includes function
7+
// Then it should return true
58
test("returns true when target is in array", () => {
69
const currentOutput = includes(["a", "b", "c", "d"], "c");
710
const targetOutput = true;
811

912
expect(currentOutput).toEqual(targetOutput);
1013
});
1114

15+
// Given an array that does not contain the target value
16+
// When passed to the includes function
17+
// Then it should return false
1218
test("returns false when target not in array", () => {
1319
const currentOutput = includes([1, 2, 3, 4], "a");
1420
const targetOutput = false;
1521

1622
expect(currentOutput).toEqual(targetOutput);
1723
});
1824

25+
// Given an array where the target appears more than once
26+
// When passed to the includes function
27+
// Then it should still return true
1928
test("returns true when the target is in array multiple times", () => {
2029
const currentOutput = includes([1, 2, 2, 3], 2);
2130
const targetOutput = true;
2231

2332
expect(currentOutput).toEqual(targetOutput);
2433
});
2534

35+
// Given an empty array
36+
// When passed to the includes function
37+
// Then it should return false
2638
test("returns false for empty array", () => {
2739
const currentOutput = includes([]);
2840
const targetOutput = false;
2941

3042
expect(currentOutput).toEqual(targetOutput);
3143
});
3244

45+
// Given an array containing null as an element
46+
// When passed to the includes function with null as the target
47+
// Then it should return true
3348
test("searches for null", () => {
3449
const currentOutput = includes(["b", "z", null, "a"], null);
3550
const targetOutput = true;

0 commit comments

Comments
 (0)