Skip to content

Instantly share code, notes, and snippets.

@sergueyarellano
Created May 26, 2021 18:36
Show Gist options
  • Save sergueyarellano/1e9f77082aacbddc977d2c3b921aa27e to your computer and use it in GitHub Desktop.
Save sergueyarellano/1e9f77082aacbddc977d2c3b921aa27e 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: {
response: {
body: [
{ a: 1, b: 2 },
{ a: 3, b: 4 },
{ a: 5, b: 6 }
]
}
}
}
const actual = mapResponse(payload)
const expected = {
data: {
mappedResponse: {
body: [
{ 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