Skip to content

Instantly share code, notes, and snippets.

@sergueyarellano
Created May 28, 2021 17:06
Show Gist options
  • Save sergueyarellano/5e6c3c55fe3b9f1379359bc01eae8259 to your computer and use it in GitHub Desktop.
Save sergueyarellano/5e6c3c55fe3b9f1379359bc01eae8259 to your computer and use it in GitHub Desktop.
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