Created
May 28, 2021 17:06
-
-
Save sergueyarellano/5e6c3c55fe3b9f1379359bc01eae8259 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('mapResponse() should map a given body response to the structure desired', async function ({ deepEqual, end }) { | |
const payload = { | |
data: { | |
config: { | |
contract: { x: 'a', y: 'b' } | |
}, | |
response: { | |
body: [ | |
{ a: 1, b: 2 }, | |
{ a: 3, b: 4 }, | |
{ a: 5, b: 6 } | |
] | |
} | |
} | |
} | |
const actual = mapResponse(deepFreeze(payload)) | |
const expected = { | |
data: { | |
config: { | |
contract: { x: 'a', y: 'b' } | |
}, | |
mappedResponse: [ | |
{ x: 1, y: 2 }, | |
{ x: 3, y: 4 }, | |
{ x: 5, y: 6 } | |
], | |
response: { | |
body: [ | |
{ a: 1, b: 2 }, | |
{ a: 3, b: 4 }, | |
{ a: 5, b: 6 } | |
] | |
} | |
} | |
} | |
deepEqual(actual, expected, 'map every element of the array to given interface') | |
end() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment