ChristmasLights.spec.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { flushPromises } from "@vue/test-utils";
  2. import ChristmasLights from "@/components/ChristmasLights.vue";
  3. import { getWrapper } from "@/tests/utils/utils";
  4. import { useUserAuthStore } from "@/stores/userAuth";
  5. describe("ChristmasLights component", () => {
  6. beforeEach(async context => {
  7. context.wrapper = await getWrapper(ChristmasLights);
  8. });
  9. test("small prop", async ({ wrapper }) => {
  10. await wrapper.setProps({
  11. small: false
  12. });
  13. expect(wrapper.classes()).not.toContain("christmas-lights-small");
  14. await wrapper.setProps({
  15. small: true
  16. });
  17. expect(wrapper.classes()).toContain("christmas-lights-small");
  18. });
  19. test("lights prop", async ({ wrapper }) => {
  20. await wrapper.setProps({
  21. lights: 10
  22. });
  23. expect(
  24. wrapper.findAll(".christmas-lights .christmas-wire").length
  25. ).toBe(10 + 1);
  26. expect(
  27. wrapper.findAll(".christmas-lights .christmas-light").length
  28. ).toBe(10);
  29. });
  30. test("loggedIn state", async ({ wrapper }) => {
  31. const userAuthStore = useUserAuthStore();
  32. expect(userAuthStore.loggedIn).toEqual(false);
  33. expect(wrapper.classes()).not.toContain("loggedIn");
  34. userAuthStore.loggedIn = true;
  35. await flushPromises();
  36. expect(userAuthStore.loggedIn).toEqual(true);
  37. expect(wrapper.classes()).toContain("loggedIn");
  38. });
  39. });