Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve MockTransport #169

Merged
merged 1 commit into from
Oct 9, 2024
Merged

Conversation

ebisbe
Copy link
Contributor

@ebisbe ebisbe commented Oct 3, 2024

Readme updates

  1. Right now params are mandatory even if empty or not needed ( like flickr.test.login case ). Not sure if that is the intended case.
  2. Missing response part.

MockTransport update

The test example is just a happy example with almost no real use case when testing another app using this package. A more likelihood scenario would be that we can require multiple queries on the same test. The current implementation of the MockTransport does not allow this. The proposal should be backwards compatible while allowing to add multiple responses to the MockTransport and returning once each time in the same order they have been added.

Example:

const transport = new MockTransport(`oauth_token=token&oauth_token_secret=secret&user_nsid=${flickrId}`)
transport.addMock({
    person: {
      username: { _content: 'Username' },
      ispro: 1,
    },
    stat: 'ok',
  })

  FetchTransport.mockImplementationOnce(() => transport)

@jeremyruppel
Copy link
Member

Thank you! This looks excellent, and definitely a lot more usable than having to create a new Flickr with a new MockTransport for every test. One suggestion might be to include a .clear() or .reset() for clearing out the responses array between tests, since MockTransport will now be stateful, but I think I'm going to merge this as is. Let me know if you come up with any other quality-of-life improvements for test scenarios

@jeremyruppel
Copy link
Member

@ebisbe we're now requiring signed commits for contributions. Is this something you can set up on your end?

@ebisbe
Copy link
Contributor Author

ebisbe commented Oct 9, 2024

@jeremyruppel I can but I'm not sure what I have to do. I'll have to figure it out. If you have a guide ( link ) that you already followed that would be perfect for me to use.

@ebisbe
Copy link
Contributor Author

ebisbe commented Oct 9, 2024

Btw, I can update with the reset / clear option and a signed commit. I'm using a fork so there's no rush on my end.

@jeremyruppel
Copy link
Member

Sure thing! The official guide can be found here.

@jeremyruppel
Copy link
Member

Oh I see, b47bec2 still isn't signed. Mind giving it a squash or rebase to sign it?

add reset function to MockTransport
@ebisbe ebisbe force-pushed the ebg/improve-mock-transport branch from 44ad804 to 2c07ad6 Compare October 9, 2024 16:11
@ebisbe
Copy link
Contributor Author

ebisbe commented Oct 9, 2024

@jeremyruppel done

@jeremyruppel jeremyruppel merged commit d4a76bd into flickr:main Oct 9, 2024
2 checks passed
@ebisbe ebisbe deleted the ebg/improve-mock-transport branch October 14, 2024 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants