Skip to content

Commit

Permalink
fix error parsing test
Browse files Browse the repository at this point in the history
  • Loading branch information
shapiromatron committed Aug 15, 2024
1 parent 2c06976 commit 39151e6
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions frontend/tests/utils/parsers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,29 @@ describe("Parsing", function() {
});

it("handles an unknown format", function() {
const expected = {
assert.deepStrictEqual(parseServerErrors("ERROR"), {
data: ["ERROR"],
messages: ["An error has occurred"],
message: "An error has occurred",
};

expected.data = ["ERROR"];
assert.deepStrictEqual(parseServerErrors("ERROR"), expected);
});

expected.data = [["ERROR"]];
assert.deepStrictEqual(parseServerErrors(["ERROR"]), expected);
assert.deepStrictEqual(parseServerErrors(["ERROR"]), {
data: ["ERROR"],
messages: ["ERROR"],
message: "ERROR",
});

expected.data = [{err: "ERROR"}];
assert.deepStrictEqual(parseServerErrors({err: "ERROR"}), expected);
assert.deepStrictEqual(parseServerErrors({err: "ERROR"}), {
data: [{err: "ERROR"}],
messages: ["An error has occurred"],
message: "An error has occurred",
});

expected.data = [[{err: "ERROR"}]];
assert.deepStrictEqual(parseServerErrors([{err: "ERROR"}]), expected);
assert.deepStrictEqual(parseServerErrors([{err: "ERROR"}]), {
data: [[{err: "ERROR"}]],
messages: ["An error has occurred"],
message: "An error has occurred",
});
});

it("handles tracebacks", function() {
Expand Down

0 comments on commit 39151e6

Please sign in to comment.