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

refactor(api): more, smaller tests #54671

Merged
merged 5 commits into from May 20, 2024

Conversation

ojeytonwilliams
Copy link
Contributor

@ojeytonwilliams ojeytonwilliams commented May 6, 2024

  • test: check get-session-user rather than db
  • refactor: rename fixtures
  • refactor: create submitExam helper function
  • refactor: rename results
  • refactor: more, smaller tests

Checklist:

I was a little unsure about what the /exam-challenge-completed endpoint was expected to do, so I split the tests up. The is a little more boilerplate as a result, but each test is now more focused. It should be clear which behaviour they're asserting.

I also moved one of the tests from checking the db directly, to using get-session-user. The reason for this is simply it's more useful to know how an update modifies the api's behaviour (i.e. how subsequent requests will play out) than how it modifies the internals. I'll extend this to the other tests in a followup PR, since that requires updating get-session-user's behaviour and I wanted to limit this to being a refactor.

@ojeytonwilliams ojeytonwilliams requested a review from a team as a code owner May 6, 2024 11:14
@github-actions github-actions bot added the platform: api Server application that needs familiarity with Express, Loopback, MongoDB etc. label May 6, 2024
@ojeytonwilliams ojeytonwilliams changed the title test: check get-session-user rather than db refactor(api): more, smaller tests May 6, 2024
Copy link
Member

@moT01 moT01 left a comment

Choose a reason for hiding this comment

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

but I left comments...

@moT01 moT01 added the status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. label May 16, 2024
Copy link
Member

@naomi-lgbt naomi-lgbt left a comment

Choose a reason for hiding this comment

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

You had me at the clearer variable names. 💜

@naomi-lgbt naomi-lgbt merged commit d06bbab into freeCodeCamp:main May 20, 2024
23 checks passed
@ojeytonwilliams ojeytonwilliams deleted the refactor/exam-tests branch May 21, 2024 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: api Server application that needs familiarity with Express, Loopback, MongoDB etc. status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants