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 unit tests #219

Merged
merged 6 commits into from Jul 26, 2022
Merged

Improve unit tests #219

merged 6 commits into from Jul 26, 2022

Commits on Jul 19, 2022

  1. Improve unit tests

    The mocks used in the external provider unit tests have been rewritten
    to allow sending and inspecting messages in either direction. They also
    no longer rely upon mocking out internal methods.
    
    The `getInitializedInpageProvider` helper function in the inpage
    provider tests has been updated with method callbacks, to allow tests
    to setup replies for specific messages. This will be used in a future
    PR.
    
    One additional test was added to ensure the `isMetaMask` property is
    set on the inpage provider.
    Gudahtt committed Jul 19, 2022
    Configuration menu
    Copy the full SHA
    afeb53a View commit details
    Browse the repository at this point in the history

Commits on Jul 20, 2022

  1. Configuration menu
    Copy the full SHA
    26185cd View commit details
    Browse the repository at this point in the history

Commits on Jul 26, 2022

  1. Configuration menu
    Copy the full SHA
    ebea8b8 View commit details
    Browse the repository at this point in the history
  2. Simplify mock provider intialization

    The initialization step of the mock provider has been simplified. The
    initialization event is awaited directly rather than using the more
    complicated decomposed promise pattern.
    Gudahtt committed Jul 26, 2022
    Configuration menu
    Copy the full SHA
    7374597 View commit details
    Browse the repository at this point in the history
  3. Improve test function return type

    The return type of `getInitializedProvider` is now an object rather
    than a tuple. This was done to improve readability. Now it's more clear
    exactly what each property is without close inspection.
    
    The return type has been improved as well. Beforehand it was inferred
    by TypeScript, but now it is explicitly declared as a type and
    documented.
    Gudahtt committed Jul 26, 2022
    Configuration menu
    Copy the full SHA
    6508da2 View commit details
    Browse the repository at this point in the history
  4. Remove protection against responding before init

    A protection measure was setup in the initialized provider helper
    function to prevent it from responding to messages before the
    initialization was complete This has been removed.
    
    It was originally added during debugging, to rule out before-
    initialization messages as an explanation for a bug that was later
    fixed I left it in because I thought that it might better match
    expectations if messages before initialization were ignored.
    
    But in retrospect, I think this would be both unnecessary and harmful.
    It's unnecessary because for most tests, no messages would be sent
    until after initialization anyway. And it's potentially harmful because
    this doesn't represent how the provider actually behaves. This could
    disguise a mistake in a test, or it could get in the way of testing
    strange edge cases surrounding initialization.
    Gudahtt committed Jul 26, 2022
    Configuration menu
    Copy the full SHA
    8eee8b8 View commit details
    Browse the repository at this point in the history