InputHelpBox.spec.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import InputHelpBox from "@/components/InputHelpBox.vue";
  2. import { getWrapper } from "@/tests/utils/utils";
  3. describe("InputHelpBox component", () => {
  4. beforeEach(async context => {
  5. context.wrapper = await getWrapper(InputHelpBox, {
  6. props: {
  7. message: "",
  8. valid: true
  9. }
  10. });
  11. });
  12. test("message prop", async ({ wrapper }) => {
  13. await wrapper.setProps({
  14. message: "This input has not been entered and is valid."
  15. });
  16. expect(wrapper.text()).toBe(
  17. "This input has not been entered and is valid."
  18. );
  19. });
  20. describe.each([
  21. { valid: true, entered: true, expected: "is-success" },
  22. { valid: true, entered: false, expected: "is-grey" },
  23. { valid: true, entered: undefined, expected: "is-success" },
  24. { valid: false, entered: true, expected: "is-danger" },
  25. { valid: false, entered: false, expected: "is-grey" },
  26. { valid: false, entered: undefined, expected: "is-danger" }
  27. ])("valid and entered props %j", ({ valid, entered, expected }) => {
  28. test("class updated", async ({ wrapper }) => {
  29. await wrapper.setProps({
  30. valid,
  31. entered
  32. });
  33. expect(wrapper.classes()).toContain(expected);
  34. });
  35. });
  36. });