Skip to content

Instantly share code, notes, and snippets.

@sergueyarellano
Created May 28, 2021 17:07
Show Gist options
  • Save sergueyarellano/03a26acb318db20f71399ea51d6bfa8e to your computer and use it in GitHub Desktop.
Save sergueyarellano/03a26acb318db20f71399ea51d6bfa8e to your computer and use it in GitHub Desktop.
{
data,
metadata
}
test('createResult() should produce a formatted structure to use as response', async function ({ deepEqual, end }) {
const payload = {
data: {
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 }
]
}
}
}
const actual = createResult(deepFreeze(payload))
const expected = {
data: {
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 }
]
}
},
result: {
data: [
{ x: 1, y: 2 },
{ x: 3, y: 4 },
{ x: 5, y: 6 }
],
metadata: {}
}
}
deepEqual(actual, expected, 'copy mappedResponse to result field and apply contract')
end()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment