Skip to content

Commit

Permalink
fix(component-library): hide protocol when re-rendering the url field
Browse files Browse the repository at this point in the history
  • Loading branch information
Haberkamp committed Feb 4, 2025
1 parent a5bf6e6 commit 0c51ffa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ import { render, screen } from "@testing-library/vue";
import userEvent from "@testing-library/user-event";

describe("mt-url-field", async () => {
it("hides the protcol in the input when re-rendering", async () => {
// ARRANGE
const { rerender } = render(MtUrlField, {
props: {
modelValue: "https://www.example.com",
},
});

// ACT
await rerender({
modelValue: "http://www.example.com",
});

// ASSERT
expect(screen.getByRole("textbox")).toHaveValue("www.example.com");
});

it("shows the domain to the user", async () => {
// ARRANGE
render(MtUrlField, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,16 @@ export default defineComponent({
},
},
created() {
// @ts-expect-error -- modelValue is always a string
const result = this.checkInput(this.currentValue);
this.currentValue = result;
watch: {
modelValue: {
handler() {
// @ts-expect-error -- modelValue is always a string
const result = this.checkInput(this.currentValue);
this.currentValue = result;
},
immediate: true,
},
},
methods: {
Expand Down

0 comments on commit 0c51ffa

Please sign in to comment.