Conditions | 5 |
Paths | 1 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /** |
||
37 | let parse = (body) => { |
||
38 | try { |
||
39 | let { |
||
40 | "output": output, |
||
41 | "comparison": { |
||
42 | "success": success, |
||
43 | "expected": expected, |
||
44 | "found": found |
||
45 | } |
||
46 | } = body; |
||
47 | if (!success && expected !== undefined && found !== undefined) { |
||
48 | let error = new CodingameError(`Expected <${body.comparison.expected}> but found <${body.comparison.found}>`); |
||
49 | return Promise.reject(error); |
||
50 | } else { |
||
51 | throw `Success value should be false when expected and found properties are provided`; |
||
52 | } |
||
53 | } catch (error) { |
||
54 | let message = `The body is not of response type '${name}'\n`; |
||
55 | message += error.message; |
||
56 | throw new Error(message); |
||
57 | } |
||
58 | }; |
||
59 | |||
64 |