Guest User

Untitled

a guest
Jul 15th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. import { render, Simulate } from "vue-testing-library";
  2. import Counter from "@/components/Counter.vue";
  3.  
  4. describe("Counter.vue", () => {
  5. it("increments by 1 on click", () => {
  6. const { getByTestId, getByText } = render(Counter);
  7. Simulate.click(getByText("Increments"));
  8. expect(getByTestId("count").textContent).toBe("1");
  9. });
  10.  
  11. it("decrements by 1 on click", () => {
  12. const { getByTestId, getByText } = render(Counter);
  13. Simulate.click(getByText("Decrements"));
  14. expect(getByTestId("count").textContent).toBe("-1");
  15. });
  16.  
  17. it("increments by multiplier", () => {
  18. const { getByTestId, getByText } = render(Counter, { props: { multiplier: 4 } });
  19. Simulate.click(getByText("Increments"));
  20. expect(getByTestId("count").textContent).toBe("4");
  21. });
  22.  
  23. it("decrements by multiplier", () => {
  24. const { getByTestId, getByText } = render(Counter, { props: { multiplier: 4 } });
  25. Simulate.click(getByText("Decrements"));
  26. expect(getByTestId("count").textContent).toBe("-4");
  27. });
  28.  
  29. it("resets to 0", () => {
  30. const { getByTestId, getByText } = render(Counter);
  31. Simulate.click(getByText("Reset"));
  32. expect(getByTestId("count").textContent).toBe("0");
  33. });
  34. });
Add Comment
Please, Sign In to add comment