Skip to content

Commit

Permalink
🛠️: refactor FormInput test to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
itisAliRH committed Apr 5, 2024
1 parent ff07413 commit 67fd056
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 37 deletions.
37 changes: 0 additions & 37 deletions client/src/components/Form/Elements/FormInput.test.js

This file was deleted.

42 changes: 42 additions & 0 deletions client/src/components/Form/Elements/FormInput.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { getLocalVue } from "@tests/jest/helpers";
import { mount, Wrapper } from "@vue/test-utils";

import FormInput from "./FormInput.vue";

const localVue = getLocalVue();

describe("FormInput", () => {
let wrapper: Wrapper<Vue>;

beforeEach(() => {
wrapper = mount(FormInput as object, {
propsData: {
id: "input",
value: "initial_value",
},
localVue,
});
});

it("check initial value and value change", async () => {
const input = wrapper.find("input");
expect((input.element as HTMLInputElement).value).toBe("initial_value");

await input.setValue("new_value");

expect((input.element as HTMLInputElement).value).toBe("new_value");
expect(wrapper.emitted().input?.[0]?.[0]).toBe("new_value");
});

it("check switching to text area", async () => {
await wrapper.setProps({ area: true });

const input = wrapper.find("textarea");
expect((input.element as HTMLInputElement).value).toBe("initial_value");

await input.setValue("new_value");

expect((input.element as HTMLInputElement).value).toBe("new_value");
expect(wrapper.emitted().input?.[0]?.[0]).toBe("new_value");
});
});

0 comments on commit 67fd056

Please sign in to comment.