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

Simplify controller tests #983

Merged
merged 11 commits into from Nov 23, 2022
Merged

Simplify controller tests #983

merged 11 commits into from Nov 23, 2022

Conversation

Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Nov 18, 2022

Rather than mocking messenger calls, I've changed the tests to use registerActionHandler. This has a few benefits:

  • The types are inferred properly, removing the need for type casts.
  • It's more readable.
  • It's easier to provide some defaults, and overwrite a single action handler if needed for a specific test.

@Mrtenz Mrtenz changed the title Simplify cronjob controller tests Simplify controller tests Nov 18, 2022
@Mrtenz Mrtenz force-pushed the mrtenz/simplify-controller-tests branch from 9ae617f to 37b2097 Compare November 18, 2022 16:57
@codecov-commenter
Copy link

codecov-commenter commented Nov 19, 2022

Codecov Report

Merging #983 (73ce156) into main (3a827c6) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #983   +/-   ##
=======================================
  Coverage   92.94%   92.94%           
=======================================
  Files          96       96           
  Lines        9578     9578           
  Branches      903      903           
=======================================
  Hits         8902     8902           
  Misses        676      676           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Mrtenz Mrtenz force-pushed the mrtenz/simplify-controller-tests branch from 3f3cc6e to e839959 Compare November 21, 2022 10:15
@Mrtenz Mrtenz marked this pull request as ready for review November 21, 2022 10:43
@Mrtenz Mrtenz requested a review from a team as a code owner November 21, 2022 10:43
packages/snaps-controllers/src/test-utils/controller.ts Outdated Show resolved Hide resolved

expect(
// Race the promises to check that handlerPromise does not time out
await Promise.race([handlerPromise, timeoutPromise]),
).toBe(true);
).toBe('test1');
Copy link
Member

Choose a reason for hiding this comment

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

Where does test1 come from here?

Copy link
Member Author

Choose a reason for hiding this comment

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

From DEFAULT_SNAP_BUNDLE. It returns method + id.

@@ -1109,14 +1058,16 @@ describe('SnapController', () => {
id: 1,
},
}),
).toBe(21896430);
).toBe(21896426);
Copy link
Member

Choose a reason for hiding this comment

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

How is this returning a number? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know. It was doing it before too though.

@Mrtenz Mrtenz force-pushed the mrtenz/simplify-controller-tests branch from a1b2681 to 73ce156 Compare November 23, 2022 11:36
@Mrtenz Mrtenz merged commit 7d7263b into main Nov 23, 2022
@Mrtenz Mrtenz deleted the mrtenz/simplify-controller-tests branch November 23, 2022 11:46
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.

None yet

3 participants