test: add input component test case

Signed-off-by: Ryan Wang <i@ryanc.cc>
pull/3445/head
Ryan Wang 2022-04-19 12:09:24 +08:00
parent fa0084e0de
commit ee0fa26c8b
2 changed files with 40 additions and 0 deletions

View File

@ -1,8 +1,20 @@
import { describe, expect, it } from "vitest";
import { VInput } from "../index";
import { mount } from "@vue/test-utils";
describe("Input", () => {
it("should render", () => {
expect(VInput).toBeDefined();
expect(mount(VInput).html()).toMatchSnapshot();
});
it("should work with size prop", function () {
["lg", "md", "sm", "xs"].forEach((size) => {
const input = mount(VInput, { props: { size } });
expect(input.html()).toMatchSnapshot();
expect(input.find("input").classes()).toContain(`input-${size}`);
input.unmount();
});
});
});

View File

@ -6,3 +6,31 @@ exports[`Input > should render 1`] = `
<!--v-if-->
</div>"
`;
exports[`Input > should work with size prop 1`] = `
"<div class=\\"input-wrapper\\">
<!--v-if--><input class=\\"input-lg\\" type=\\"text\\">
<!--v-if-->
</div>"
`;
exports[`Input > should work with size prop 2`] = `
"<div class=\\"input-wrapper\\">
<!--v-if--><input class=\\"input-md\\" type=\\"text\\">
<!--v-if-->
</div>"
`;
exports[`Input > should work with size prop 3`] = `
"<div class=\\"input-wrapper\\">
<!--v-if--><input class=\\"input-sm\\" type=\\"text\\">
<!--v-if-->
</div>"
`;
exports[`Input > should work with size prop 4`] = `
"<div class=\\"input-wrapper\\">
<!--v-if--><input class=\\"input-xs\\" type=\\"text\\">
<!--v-if-->
</div>"
`;