Skip to content

Commit f5247f1

Browse files
committed
format document for describe-median test
1 parent a0de919 commit f5247f1

1 file changed

Lines changed: 27 additions & 21 deletions

File tree

‎Sprint-1/implement/describe-median.test.js‎

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,31 @@ const describeMedian = require("./describe-median.js");
2222
// Then it should return "The median is " followed by the median
2323
// Delete this test.todo and replace it with a test.
2424
describe("describeMedian", () => {
25-
it("returns for [1, 2, 3, 4]", () => {
26-
const array = [1, 2, 3, 4]
27-
const result = describeMedian(array);
28-
expect(result).toBe('The median is 2.5')
29-
})
30-
31-
// Given an empty array
32-
// When passed to describeMedian
33-
// Then it should return "Could not calculate a median: calculateMedian requires a non-empty array"
34-
it ("returns for []", () => {
25+
it("returns for [1, 2, 3, 4]", () => {
26+
const array = [1, 2, 3, 4];
27+
const result = describeMedian(array);
28+
expect(result).toBe("The median is 2.5");
29+
});
30+
31+
// Given an empty array
32+
// When passed to describeMedian
33+
// Then it should return "Could not calculate a median: calculateMedian requires a non-empty array"
34+
it("returns for []", () => {
3535
expect(() => describeMedian([])).toThrow(
36-
new Error("Could not calculate a median: calculateMedian requires a non-empty array"))
37-
})
38-
39-
// Given something that isn't an array of numbers, e.g. "banana"
40-
// When passed to describeMedian
41-
// Then it should return "Could not calculate a median: calculateMedian requires an array of numbers"
42-
it ("returns for ['banana', 'apple', 'orange']", () => {
43-
expect(() => describeMedian(['banana', 'apple', 'orange'])).toThrow(
44-
new Error("Could not calculate a median: calculateMedian requires an array of numbers"))
45-
})
46-
})
36+
new Error(
37+
"Could not calculate a median: calculateMedian requires a non-empty array"
38+
)
39+
);
40+
});
41+
42+
// Given something that isn't an array of numbers, e.g. "banana"
43+
// When passed to describeMedian
44+
// Then it should return "Could not calculate a median: calculateMedian requires an array of numbers"
45+
it("returns for ['banana', 'apple', 'orange']", () => {
46+
expect(() => describeMedian(["banana", "apple", "orange"])).toThrow(
47+
new Error(
48+
"Could not calculate a median: calculateMedian requires an array of numbers"
49+
)
50+
);
51+
});
52+
});

0 commit comments

Comments
 (0)