Created
January 19, 2022 13:56
-
-
Save klippx/1996f2a256b0cd06e6a6e8b78b590bb9 to your computer and use it in GitHub Desktop.
This file contains 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
it('can create a mock with specific body where order of keys does not matter', async () => { | |
const mock = mockClient(client) | |
.resource('Blog') | |
.method('post') | |
.status(204) | |
.with({ | |
body: JSON.stringify({ | |
title: 'title', | |
data: { | |
nestedItemOne: 1, | |
nestedItemTwo: 2, | |
nestingLevelTwo: { | |
deepNestedItemOne: 1, | |
deepNestedItemTwo: 2, | |
}, | |
}, | |
}), | |
}) | |
.response({ ok: true }) | |
.assertObject() | |
const response = await client.Blog.post({ | |
body: JSON.stringify({ | |
title: 'title', | |
data: { | |
nestedItemOne: 1, | |
nestedItemTwo: 2, | |
nestingLevelTwo: { | |
deepNestedItemOne: 1, | |
deepNestedItemTwo: 2, | |
}, | |
}, | |
}), | |
}) | |
expect(response.data()).toEqual({ ok: true }) | |
expect(mock.callsCount()).toEqual(1) | |
const response2 = await client.Blog.post({ | |
body: JSON.stringify({ | |
title: 'title', | |
data: { | |
nestedItemTwo: 2, | |
nestedItemOne: 1, | |
nestingLevelTwo: { | |
deepNestedItemTwo: 2, | |
deepNestedItemOne: 1, | |
}, | |
}, | |
}), | |
}) | |
expect(response2.data()).toEqual({ ok: true }) | |
expect(mock.callsCount()).toEqual(2) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment