Skip to content

Commit 577ae89

Browse files
Refactor query string tests for improved clarity and structure
1 parent 493e3f1 commit 577ae89

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

Sprint-2/implement/querystring.test.js

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,52 @@
33
// Below is one test case for an edge case the implementation doesn't handle well.
44
// Fix the implementation for this test, and try to think of as many other edge cases as possible - write tests and fix those too.
55

6-
const parseQueryString = require("./querystring.js")
6+
const parseQueryString = require("./querystring.js");
77

88
test("parses querystring values containing =", () => {
9-
expect(parseQueryString("equation=x=y+1")).toEqual({
10-
"equation": "x=y+1",
9+
expect(parseQueryString("equation=x=y+1")).toEqual({ equation: "x=y+1" });
10+
});
11+
12+
test("parse querystring with multiple values", () => {
13+
expect(parseQueryString("equation=x=y+1&sound=none")).toEqual({
14+
equation: "x=y+1",
15+
sound: "none",
1116
});
1217
});
18+
19+
test("parse querystring with multiple ==", () => {
20+
expect(parseQueryString("equation==x=y+1&sound=none")).toEqual({
21+
equation: "=x=y+1",
22+
sound: "none",
23+
});
24+
});
25+
26+
test("parse querystring with multiple &&", () => {
27+
expect(parseQueryString("equation=x=y+1&&sound=none")).toEqual({
28+
equation: "x=y+1",
29+
sound: "none",
30+
});
31+
});
32+
33+
test("parse querystring with no =", () => {
34+
expect(parseQueryString("equation=x=y+1&soundnone")).toEqual({
35+
equation: "x=y+1",
36+
soundnone:"",
37+
});
38+
});
39+
40+
//don't know how to do this
41+
// test("parse querystring with multiple ==", () => {
42+
// expect(parseQueryString("equation==x=y+1&sound=none")).toEqual({
43+
// equation=: "x=y+1",
44+
// sound: "none",
45+
// });
46+
// });
47+
48+
//don't know how to do this
49+
// test("parses querystring values containing &", () => {
50+
// expect(parseQueryString("&equation=x=y+1&sound=none")).toEqual({
51+
// "&equation": "x=y+1",
52+
// sound: "none",
53+
// });
54+
// });

0 commit comments

Comments
 (0)