it('should send correct payload', async () => { fetchMock.patchOnce( `https://samples.auth0.com/api/v2/users/${encodeURIComponent(userId)}`, user ); expect.assertions(1); await users.patchUser({ id: userId, metadata }); expect(fetchMock.lastCall()).toMatchSnapshot(); });
it('should return successful response', async () => { fetchMock.patchOnce( `https://samples.auth0.com/api/v2/users/${encodeURIComponent(userId)}`, user ); expect.assertions(1); await expect( users.patchUser({ id: userId, metadata }) ).resolves.toMatchSnapshot(); });
it('should handle unexpected error', async () => { fetchMock.patchOnce( `https://samples.auth0.com/api/v2/users/${encodeURIComponent(userId)}`, unexpectedError ); expect.assertions(1); await expect( users.patchUser({ id: userId, metadata }) ).rejects.toMatchSnapshot(); });