From b34ca0fb0c209b8a75fe87f531fd6dcab3e8be28 Mon Sep 17 00:00:00 2001
From: Faizal Andyka <logustra@gmail.com>
Date: Tue, 7 Jun 2022 12:08:21 +0700
Subject: [PATCH] refactor(components): [link] use JSX in Unit test (#8140)

---
 .../__tests__/{link.test.ts => link.test.tsx} | 45 +++++++------------
 1 file changed, 17 insertions(+), 28 deletions(-)
 rename packages/components/link/__tests__/{link.test.ts => link.test.tsx} (52%)

diff --git a/packages/components/link/__tests__/link.test.ts b/packages/components/link/__tests__/link.test.tsx
similarity index 52%
rename from packages/components/link/__tests__/link.test.ts
rename to packages/components/link/__tests__/link.test.tsx
index ad7d3256b012d..6dc94498ae502 100644
--- a/packages/components/link/__tests__/link.test.ts
+++ b/packages/components/link/__tests__/link.test.tsx
@@ -6,47 +6,36 @@ const AXIOM = 'Rem is the best girl'
 
 describe('Link.vue', () => {
   it('render test', () => {
-    const wrapper = mount(Link, {
-      slots: {
-        default: AXIOM,
-      },
-    })
+    const wrapper = mount(() => <Link>{AXIOM}</Link>)
+
     expect(wrapper.text()).toEqual(AXIOM)
   })
 
   it('it should handle click event when link is not disabled', async () => {
-    const wrapper = mount(Link, {
-      slots: {
-        default: AXIOM,
-      },
-    })
+    const wrapper = mount(() => <Link>{AXIOM}</Link>)
 
-    await wrapper.find('.el-link').trigger('click')
+    await wrapper.trigger('click')
     expect(wrapper.emitted('click')).toHaveLength(1)
   })
 
   it('it should disable click when link is disabled', async () => {
-    const wrapper = mount(Link, {
-      slots: {
-        default: AXIOM,
-      },
-      props: {
-        disabled: true,
-      },
-    })
-
-    await wrapper.find('.el-link').trigger('click')
-    expect(wrapper.emitted('click')).toBeUndefined()
+    const wrapper = mount(() => <Link disabled>{AXIOM}</Link>)
+
+    expect(wrapper.classes()).toContain('is-disabled')
+    expect(wrapper.attributes('href')).toBeUndefined()
   })
 
   it('icon slots', () => {
     const linkName = 'test link'
-    const wrapper = mount(Link, {
-      slots: {
-        default: linkName,
-        icon: AXIOM,
-      },
-    })
+
+    const wrapper = mount(() => (
+      <Link
+        v-slots={{
+          default: () => linkName,
+          icon: () => AXIOM,
+        }}
+      />
+    ))
     expect(wrapper.text()).toContain(linkName)
     expect(wrapper.text()).toContain(AXIOM)
   })