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

Add tests for useSignInAnonymouslyMutation hook #103

Merged

Conversation

HassanBahati
Copy link
Collaborator

@HassanBahati HassanBahati commented Sep 25, 2024

this pr adds tests to useSignInAnonymouslyMutation hook

Copy link

docs-page bot commented Sep 25, 2024

To view this pull requests documentation preview, visit the following URL:

react-query-firebase.invertase.dev/~103

Documentation is deployed and generated using docs.page.

import { useSignInAnonymouslyMutation } from "./useSignInAnonymouslyMutation";

vi.mock("firebase/auth", () => ({
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Ehesp i did have 2 options here when mocking the firebase auth module

  1. Option One (seemed simple and its what i went with)
// this ignores all other imports from the module 
// and only mocks the specific function 'signInAnonymously'
vi.mock("firebase/auth", () => ({
  signInAnonymously: vi.fn(),
}));
  1. Option Two
//
vi.mock("firebase/auth", async (importOriginal) => {
  // Import the original 'firebase/auth' module
  const module = await importOriginal<typeof import("firebase/auth")>();

  // Return a mocked version of the module
  return {
    ...module, // Spread in all the original functions from the module
    signInAnonymously: vi.fn(), // Mock the specific function 'signInAnonymously'
  };
});

do you think it would be better to with option 2 that returns a mocked version of the module with all original functions ?

@HassanBahati HassanBahati requested a review from Ehesp September 25, 2024 17:54
@Ehesp Ehesp merged commit 2e73cfa into invertase:next Sep 26, 2024
2 of 4 checks passed
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