-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ab9642
commit b392626
Showing
2 changed files
with
73 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
import userEvent from "@testing-library/user-event"; | ||
import { render, screen, fireEvent } from "@testing-library/vue"; | ||
import { describe, expect, it } from "vitest"; | ||
import { reactive } from "vue"; | ||
import { reactive, ref } from "vue"; | ||
import AuthForm from "./AtAuthForm.vue"; | ||
|
||
describe("AuthForm component", () => { | ||
|
@@ -92,9 +92,57 @@ describe("AuthForm component", () => { | |
}); | ||
}); | ||
|
||
it("Should render the component register", async () => { | ||
it("Should change email on initial value change", async () => { | ||
const initialValues = ref({ | ||
email: "", | ||
}); | ||
|
||
const email = "[email protected]"; | ||
|
||
const component = render(AuthForm, { | ||
props: { | ||
mode: "register", | ||
initialValues: initialValues, | ||
config: { | ||
email: { | ||
disabled: true | ||
} | ||
} | ||
}, | ||
}); | ||
|
||
initialValues.value.email = email; | ||
const inputEmail = await component.findByTestId("input-email"); | ||
expect(inputEmail.value).toBe(email); | ||
}); | ||
it("Should disable email on config set", async () => { | ||
const initialValues = ref({ | ||
email: "", | ||
}); | ||
|
||
const email = "[email protected]"; | ||
|
||
const component = render(AuthForm, { | ||
props: { | ||
mode: "register", | ||
initialValues: initialValues, | ||
config: { | ||
email: { | ||
disabled: true | ||
} | ||
} | ||
}, | ||
}); | ||
|
||
initialValues.value.email = email; | ||
const inputEmail = await component.findByTestId("input-email"); | ||
await userEvent.type(inputEmail, "[email protected]") | ||
expect(inputEmail.value).toBe(email); | ||
}); | ||
|
||
it("Should disable email after initialization in register", async () => { | ||
const initialValues = reactive({ | ||
email: "[email protected]", | ||
email: "", | ||
}); | ||
|
||
const component = render(AuthForm, { | ||
|
@@ -103,6 +151,8 @@ describe("AuthForm component", () => { | |
}, | ||
}); | ||
|
||
initialValues.email = "[email protected]" | ||
|
||
component.findByText("[email protected]"); | ||
initialValues.email = "[email protected]"; | ||
component.findByText("[email protected]"); | ||
|
This file contains 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