Skip to content

Commit f207de3

Browse files
committed
fix(react,shadcn): onBackToSignIn -> onSignInClick
1 parent 217de0c commit f207de3

File tree

8 files changed

+25
-26
lines changed

8 files changed

+25
-26
lines changed

examples/react/src/screens/sign-up-auth-screen-w-handlers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function SignUpAuthScreenWithHandlersPage() {
2424

2525
return (
2626
<SignUpAuthScreen
27-
onBackToSignInClick={() => {
27+
onSignInClick={() => {
2828
navigate("/screens/sign-in-auth-screen");
2929
}}
3030
onSignUp={(credential) => {

packages/react/src/auth/forms/sign-up-auth-form.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ describe("<SignUpAuthForm />", () => {
282282
expect(createAccountButton).toHaveAttribute("type", "submit");
283283
});
284284

285-
it("should render the back to sign in button callback when onBackToSignInClick is provided", () => {
285+
it("should render the back to sign in button callback when onSignInClick is provided", () => {
286286
const mockUI = createMockUI({
287287
locale: registerLocale("test", {
288288
prompts: {
@@ -294,11 +294,11 @@ describe("<SignUpAuthForm />", () => {
294294
}),
295295
});
296296

297-
const onBackToSignInClickMock = vi.fn();
297+
const onSignInClickMock = vi.fn();
298298

299299
render(
300300
<FirebaseUIProvider ui={mockUI}>
301-
<SignUpAuthForm onBackToSignInClick={onBackToSignInClickMock} />
301+
<SignUpAuthForm onSignInClick={onSignInClickMock} />
302302
</FirebaseUIProvider>
303303
);
304304

@@ -312,7 +312,7 @@ describe("<SignUpAuthForm />", () => {
312312
expect(backToSignInButton).toHaveAttribute("type", "button");
313313

314314
fireEvent.click(backToSignInButton);
315-
expect(onBackToSignInClickMock).toHaveBeenCalled();
315+
expect(onSignInClickMock).toHaveBeenCalled();
316316
});
317317

318318
it("should trigger validation errors when the form is blurred", () => {

packages/react/src/auth/forms/sign-up-auth-form.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function useRequireDisplayName() {
3131

3232
export type SignUpAuthFormProps = {
3333
onSignUp?: (credential: UserCredential) => void;
34-
onBackToSignInClick?: () => void;
34+
onSignInClick?: () => void;
3535
};
3636

3737
export function useSignUpAuthFormAction() {
@@ -79,7 +79,7 @@ export function useSignUpAuthForm(onSuccess?: SignUpAuthFormProps["onSignUp"]) {
7979
});
8080
}
8181

82-
export function SignUpAuthForm({ onBackToSignInClick, onSignUp }: SignUpAuthFormProps) {
82+
export function SignUpAuthForm({ onSignInClick, onSignUp }: SignUpAuthFormProps) {
8383
const ui = useUI();
8484
const form = useSignUpAuthForm(onSignUp);
8585
const requireDisplayName = useRequireDisplayName();
@@ -116,8 +116,8 @@ export function SignUpAuthForm({ onBackToSignInClick, onSignUp }: SignUpAuthForm
116116
<form.SubmitButton>{getTranslation(ui, "labels", "createAccount")}</form.SubmitButton>
117117
<form.ErrorMessage />
118118
</fieldset>
119-
{onBackToSignInClick ? (
120-
<form.Action onClick={onBackToSignInClick}>
119+
{onSignInClick ? (
120+
<form.Action onClick={onSignInClick}>
121121
{getTranslation(ui, "prompts", "haveAccount")} {getTranslation(ui, "labels", "signIn")}
122122
</form.Action>
123123
) : null}

packages/react/src/auth/screens/sign-up-auth-screen.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import { registerLocale } from "@firebase-ui/translations";
2121
import { MultiFactorResolver } from "firebase/auth";
2222

2323
vi.mock("~/auth/forms/sign-up-auth-form", () => ({
24-
SignUpAuthForm: ({ onBackToSignInClick }: { onBackToSignInClick?: () => void }) => (
24+
SignUpAuthForm: ({ onSignInClick }: { onSignInClick?: () => void }) => (
2525
<div data-testid="sign-up-auth-form">
26-
<button data-testid="back-to-sign-in-button" onClick={onBackToSignInClick}>
26+
<button data-testid="back-to-sign-in-button" onClick={onSignInClick}>
2727
Back to Sign In
2828
</button>
2929
</div>
@@ -100,20 +100,20 @@ describe("<SignUpAuthScreen />", () => {
100100
expect(screen.getByTestId("sign-up-auth-form")).toBeDefined();
101101
});
102102

103-
it("passes onBackToSignInClick to SignUpAuthForm", () => {
104-
const mockOnBackToSignInClick = vi.fn();
103+
it("passes onSignInClick to SignUpAuthForm", () => {
104+
const mockOnSignInClick = vi.fn();
105105
const ui = createMockUI();
106106

107107
render(
108108
<CreateFirebaseUIProvider ui={ui}>
109-
<SignUpAuthScreen onBackToSignInClick={mockOnBackToSignInClick} />
109+
<SignUpAuthScreen onSignInClick={mockOnSignInClick} />
110110
</CreateFirebaseUIProvider>
111111
);
112112

113113
const backButton = screen.getByTestId("back-to-sign-in-button");
114114
fireEvent.click(backButton);
115115

116-
expect(mockOnBackToSignInClick).toHaveBeenCalledTimes(1);
116+
expect(mockOnSignInClick).toHaveBeenCalledTimes(1);
117117
});
118118

119119
it("renders a divider with children when present", () => {

packages/shadcn/src/components/multi-factor-auth-assertion-screen.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,3 @@ describe("<MultiFactorAuthAssertionScreen />", () => {
116116
expect(card).toBeInTheDocument();
117117
});
118118
});
119-

packages/shadcn/src/components/sign-up-auth-form.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe("<SignUpAuthForm />", () => {
6969
});
7070

7171
it("should render with back to sign in callback", () => {
72-
const onBackToSignInClickMock = vi.fn();
72+
const onSignInClickMock = vi.fn();
7373
const mockUI = createMockUI({
7474
locale: registerLocale("test", {
7575
prompts: {
@@ -83,7 +83,7 @@ describe("<SignUpAuthForm />", () => {
8383

8484
const { container } = render(
8585
<FirebaseUIProvider ui={mockUI}>
86-
<SignUpAuthForm onBackToSignInClick={onBackToSignInClickMock} />
86+
<SignUpAuthForm onSignInClick={onSignInClickMock} />
8787
</FirebaseUIProvider>
8888
);
8989

@@ -95,7 +95,7 @@ describe("<SignUpAuthForm />", () => {
9595
fireEvent.click(button!);
9696
});
9797

98-
expect(onBackToSignInClickMock).toHaveBeenCalled();
98+
expect(onSignInClickMock).toHaveBeenCalled();
9999
});
100100

101101
it("should call the onSignUp callback when the form is submitted", async () => {

packages/shadcn/src/components/sign-up-auth-form.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ export function SignUpAuthForm(props: SignUpAuthFormProps) {
9393
{getTranslation(ui, "labels", "createAccount")}
9494
</Button>
9595
{form.formState.errors.root && <FormMessage>{form.formState.errors.root.message}</FormMessage>}
96-
{props.onBackToSignInClick ? (
97-
<Button type="button" variant="link" size="sm" onClick={props.onBackToSignInClick}>
96+
{props.onSignInClick ? (
97+
<Button type="button" variant="link" size="sm" onClick={props.onSignInClick}>
9898
<span className="text-xs">
9999
{getTranslation(ui, "prompts", "haveAccount")} {getTranslation(ui, "labels", "signIn")}
100100
</span>

packages/shadcn/src/components/sign-up-auth-screen.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import { FirebaseUIProvider } from "@firebase-ui/react";
2323
import { MultiFactorResolver } from "firebase/auth";
2424

2525
vi.mock("./sign-up-auth-form", () => ({
26-
SignUpAuthForm: ({ onSignUp, onBackToSignInClick }: any) => (
26+
SignUpAuthForm: ({ onSignUp, onSignInClick }: any) => (
2727
<div data-testid="sign-up-auth-form">
2828
<div>SignUpAuthForm</div>
2929
{onSignUp && <div data-testid="onSignUp-prop">onSignUp provided</div>}
30-
{onBackToSignInClick && <div data-testid="onBackToSignInClick-prop">onBackToSignInClick provided</div>}
30+
{onSignInClick && <div data-testid="onSignInClick-prop">onSignInClick provided</div>}
3131
</div>
3232
),
3333
}));
@@ -116,16 +116,16 @@ describe("<SignUpAuthScreen />", () => {
116116
});
117117

118118
const onSignUpMock = vi.fn();
119-
const onBackToSignInClickMock = vi.fn();
119+
const onSignInClickMock = vi.fn();
120120

121121
render(
122122
<FirebaseUIProvider ui={mockUI}>
123-
<SignUpAuthScreen onSignUp={onSignUpMock} onBackToSignInClick={onBackToSignInClickMock} />
123+
<SignUpAuthScreen onSignUp={onSignUpMock} onSignInClick={onSignInClickMock} />
124124
</FirebaseUIProvider>
125125
);
126126

127127
expect(screen.getByTestId("onSignUp-prop")).toBeInTheDocument();
128-
expect(screen.getByTestId("onBackToSignInClick-prop")).toBeInTheDocument();
128+
expect(screen.getByTestId("onSignInClick-prop")).toBeInTheDocument();
129129
});
130130

131131
it("should not render separator when no children", () => {

0 commit comments

Comments
 (0)