ソースを参照

chore(actionsheet): use icons-vue component and fix unit test (#1928)

* chore(actionsheet): use icons-vue component and fix unit test

* chore(actionsheet): fix global components configuration
Kason Yang 3 年 前
コミット
9e2aa2ad4f

+ 5 - 5
src/packages/__VUE/actionsheet/__test__/index.spec.ts

@@ -1,13 +1,13 @@
 import { config, mount } from '@vue/test-utils';
 import ActionSheet from '../index.vue';
-import NutIcon from '../../icon/index.vue';
 import NutPopup from '../../popup/index.vue';
+import { Loading } from '@nutui/icons-vue';
 import { nextTick } from 'vue';
 
 beforeAll(() => {
   config.global.components = {
-    NutIcon,
-    NutPopup
+    NutPopup,
+    Loading
   };
 });
 
@@ -68,7 +68,7 @@ test('should render sure actionsheet when use custom props', () => {
   });
 
   expect(wrapper.html()).toMatchSnapshot();
-  let subdesc = wrapper.find('.subdesc');
+  let subdesc = wrapper.find('.nut-action-sheet__subdesc');
   expect(subdesc.html()).toContain('描述信息');
 });
 
@@ -123,7 +123,7 @@ test('should render description when use description', async () => {
       menuItems: [{ name: '选项一', disabled: true }]
     }
   });
-  let desc = wrapper.find('.desc');
+  let desc = wrapper.find('.nut-action-sheet__desc');
   let title = wrapper.find('.nut-action-sheet__title');
   expect(desc.exists()).toBeTruthy();
   expect(title.exists()).toBeTruthy();

+ 4 - 2
src/packages/__VUE/actionsheet/index.taro.vue

@@ -17,7 +17,7 @@
             :key="index"
             @click="chooseItem(item, index)"
           >
-            <nut-icon v-if="item.loading" name="loading"> </nut-icon>
+            <loading v-if="item.loading"></loading>
             <view v-else> {{ item[optionTag] }}</view>
             <view class="nut-action-sheet__subdesc">{{ item[optionSubTag] }}</view>
           </view>
@@ -36,6 +36,7 @@ import type { PropType } from 'vue';
 const { componentName, create } = createComponent('action-sheet');
 import Popup from '../popup/index.taro.vue';
 import { popupProps } from '../popup/props';
+import { Loading } from '@nutui/icons-vue';
 export interface menuItems {
   disable: boolean;
   loading: boolean;
@@ -46,7 +47,8 @@ export interface menuItems {
 }
 export default create({
   components: {
-    [Popup.name]: Popup
+    [Popup.name]: Popup,
+    [Loading.name]: Loading
   },
   props: {
     ...popupProps,

+ 4 - 2
src/packages/__VUE/actionsheet/index.vue

@@ -24,7 +24,7 @@
             :key="index"
             @click="chooseItem(item, index)"
           >
-            <nut-icon v-if="item.loading" name="loading"> </nut-icon>
+            <loading v-if="item.loading"></loading>
             <view v-else> {{ item[optionTag] }}</view>
             <view class="nut-action-sheet__subdesc">{{ item[optionSubTag] }}</view>
           </view>
@@ -42,6 +42,7 @@ import { computed, useSlots } from 'vue';
 import type { PropType } from 'vue';
 import { popupProps } from '../popup/props';
 import Popup from '../popup/index.vue';
+import { Loading } from '@nutui/icons-vue';
 const { componentName, create } = createComponent('action-sheet');
 export interface menuItems {
   disable: boolean;
@@ -53,7 +54,8 @@ export interface menuItems {
 }
 export default create({
   components: {
-    [Popup.name]: Popup
+    [Popup.name]: Popup,
+    [Loading.name]: Loading
   },
   props: {
     ...popupProps,