test: let the mock hold the world, instead of building it here - #25
Merged
Merged
Conversation
Two test files stubbed `game.items` by hand, because the mock's was an empty array and the code under test walks the collection. One of them also stubbed `game.journal` down to a single `find`. `@vttforge/testing` 0.14.0 makes those real collections and takes the documents as options, so both stubs are gone and the fixtures are passed straight in. `asUser` in the API test drops from nine lines to two. Same fixtures, same 31 tests.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two test files stubbed
game.itemsby hand, because the mock's was an empty array and the code under test walks the collection.tests/export.test.tsalso stubbedgame.journaldown to a singlefind.@vttforge/testing0.14.0 makes those real collections and takes the documents as options, so both stubs are gone:asUserin the API test drops from nine lines to two. Same fixtures, same 31 tests.This is the third round of the same loop: the module needed something, the mock did not have it, the SDK grew it, and the module deleted the workaround. The stubs it deletes here are the ones written two PRs ago when the code started walking
game.itemsinstead of filtering it.pnpm run typecheckis clean and the 31 unit tests pass.