|
3 | 3 | // Below is one test case for an edge case the implementation doesn't handle well. |
4 | 4 | // Fix the implementation for this test, and try to think of as many other edge cases as possible - write tests and fix those too. |
5 | 5 |
|
6 | | -const parseQueryString = require("./querystring.js") |
| 6 | +const parseQueryString = require("./querystring.js"); |
7 | 7 |
|
8 | 8 | 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", |
11 | 16 | }); |
12 | 17 | }); |
| 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