RestCard.sample 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { mount } from "@vue/test-utils"
  2. import RestCard from "../rest/Card"
  3. const factory = (props) => {
  4. return mount(RestCard, {
  5. propsData: props,
  6. mocks: {
  7. $t: (text) => text,
  8. },
  9. directives: {
  10. tooltip() {
  11. /* stub */
  12. },
  13. closePopover() {
  14. /* stub */
  15. },
  16. },
  17. })
  18. }
  19. const url = "https://dummydata.com/get"
  20. const entry = {
  21. type: "rest",
  22. url,
  23. method: "GET",
  24. status: 200,
  25. star: false,
  26. }
  27. describe("RestCard", () => {
  28. test("Mounts properly if props are given", () => {
  29. const wrapper = factory({ entry })
  30. expect(wrapper).toBeTruthy()
  31. })
  32. // test("toggle-star emitted on clicking on star button", async () => {
  33. // const wrapper = factory({ entry })
  34. // await wrapper.find("button[data-testid='star_button']").trigger("click")
  35. // expect(wrapper.emitted("toggle-star")).toBeTruthy()
  36. // })
  37. // test("use-entry emit on clicking the restore button", async () => {
  38. // const wrapper = factory({ entry })
  39. // await wrapper
  40. // .find("button[data-testid='restore_history_entry']")
  41. // .trigger("click")
  42. // expect(wrapper.emitted("use-entry")).toBeTruthy()
  43. // })
  44. // test("delete-entry emit on clicking the delete button", async () => {
  45. // const wrapper = factory({ entry })
  46. // await wrapper
  47. // .find("button[data-testid=delete_history_entry]")
  48. // .trigger("click")
  49. // expect(wrapper.emitted("delete-entry")).toBeTruthy()
  50. // })
  51. })