Skip to content

Instantly share code, notes, and snippets.

@sergueyarellano
Created May 28, 2021 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergueyarellano/02839c61c322cd6ab45182cb5b678e58 to your computer and use it in GitHub Desktop.
Save sergueyarellano/02839c61c322cd6ab45182cb5b678e58 to your computer and use it in GitHub Desktop.
test('setWith() takes a path and a function', async function ({ deepEqual, end }) {
const payload = {
event: {
body: '{"a": 1, "foo": "bar"}'
}
}
const result = setWith('event.body', JSON.parse)(deepFreeze(payload))
const actual = result.event.body
const expected = { a: 1, foo: 'bar' }
deepEqual(actual, expected, 'applies JSON.parse to the value assigned to that path')
end()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment