Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Better test #16

Merged
merged 8 commits into from
Jan 19, 2021
Merged

Better test #16

merged 8 commits into from
Jan 19, 2021

Conversation

chaiwa-berian
Copy link
Contributor

The tests for get and post pass but the tests for patch,put, and del fail with the error TypeError: Cannot convert undefined or null to object. @stuartc Kindly review and advise. After the last three pass, this PR should fix #13 .

@stuartc stuartc self-assigned this Jan 19, 2021
@stuartc
Copy link
Member

stuartc commented Jan 19, 2021

@chaiwa-berian I think I found the issue/s:

  1. composeNextState expects there to be a references key in the state, which only exists if you call the operations with execute(...) (that adds a references key to the state before calling the operations).
  2. The response body you are sending in the nock reply has the key body in it. But there is also some strange (probably always been like this) behaviour around tryJson and how the generic req function handles responses...
    I'm going to leave that stuff alone since I think between us stubbing the response with nock and us about to move away from request I don't want to spend more time on that..

So yeah long story short the tests are passing now.

});
});

describe('delete', () => {
before(() => {
testServer.delete('/api/fake-del-items/6').reply(204, function (url, body) {
return {};
return JSON.stringify({});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing significant about this, but it does test that the body is turned back into an object via tryJson.

@stuartc stuartc merged commit 6392340 into master Jan 19, 2021
@stuartc stuartc deleted the better-test branch January 19, 2021 12:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve tests
3 participants