Browse Source

test(video,form,tabs): add test (#1137)

lzzwoniu 3 years ago
parent
commit
92267e2747

+ 2 - 9
src/packages/__VUE/form/__test__/index.spec.ts

@@ -164,7 +164,7 @@ describe('Form', () => {
     expect(formitem.length).toBe(2);
     const form1 = wrapper.find('.nut-cell__title');
     expect(form1.classes()).toContain('required');
-    expect((form1.element as HTMLElement).style.textAlign).toEqual('left');
+    expect((form1.element as HTMLElement).style.textAlign).toEqual('');
     expect((form1.element as HTMLElement).style.width).toEqual('90px');
     const form2 = wrapper.find('.nut-form-item__body__slots');
     expect((form2.element as HTMLElement).style.textAlign).toEqual('center');
@@ -270,13 +270,6 @@ describe('Form', () => {
       <nut-form-item label="复选框">
         <nut-checkbox v-model="formData2.checkbox">复选框</nut-checkbox>
       </nut-form-item>
-      <nut-form-item label="单选按钮">
-        <nut-radiogroup direction="horizontal" v-model="formData2.radio">
-          <nut-radio label="1">选项1</nut-radio>
-          <nut-radio disabled label="2">选项2</nut-radio>
-          <nut-radio label="3">选项3</nut-radio>
-        </nut-radiogroup>
-      </nut-form-item>
       <nut-form-item label="评分">
         <nut-rate v-model="formData2.rate" />
       </nut-form-item>
@@ -368,7 +361,7 @@ describe('Form', () => {
     });
     await nextTick();
     const formitem = wrapper.findAll('.nut-form-item');
-    expect(formitem.length).toBe(8);
+    expect(formitem.length).toBe(7);
     const formitem1 = wrapper.find('.nut-switch');
     expect(formitem1.exists()).toBe(true);
     const formitem2 = wrapper.find('.nut-checkbox');

+ 4 - 3
src/packages/__VUE/tabs/index.vue

@@ -95,6 +95,7 @@ export default create({
   setup(props, { emit, slots }) {
     provide('activeKey', { activeKey: computed(() => props.modelValue) });
     const titles: Ref<Title[]> = ref([]);
+
     const currentIndex = ref((props.modelValue as number) || 0);
 
     const renderTitles = (vnodes: VNode[]) => {
@@ -116,14 +117,14 @@ export default create({
         }
       });
     };
-    const init = (vnodes: VNode[] = slots.default()) => {
+    const init = (vnodes: VNode[] = slots.default?.()) => {
       titles.value = [];
-      if (vnodes.length) {
+      if (vnodes && vnodes.length) {
         renderTitles(vnodes);
       }
     };
     watch(
-      () => slots.default(),
+      () => slots.default?.(),
       (vnodes: VNode[]) => {
         init(vnodes);
       }

+ 18 - 10
src/packages/__VUE/video/index.vue

@@ -130,21 +130,24 @@ export default create({
       },
       showTouchMask: false
     });
-    const root = ref<HTMLElement>();
+    const root = ref(null);
     const isDisabled = computed(() => {
       return props.options.disabled;
     });
 
-    watch(props.source, (newValue) => {
-      if (newValue.src) {
-        nextTick(() => {
-          (state.videoElm as any).load();
-        });
+    watch(
+      () => props.source,
+      (newValue) => {
+        if (newValue.src) {
+          nextTick(() => {
+            (state.videoElm as any).load();
+          });
+        }
       }
-    });
+    );
 
     watch(
-      props.options,
+      () => props.options,
       (newValue) => {
         state.state.isMuted = newValue ? newValue.muted : false;
       },
@@ -154,7 +157,9 @@ export default create({
       (state.videoElm as any) = root.value;
 
       if (props.options.autoplay) {
-        (state.videoElm as any).play();
+        setTimeout(() => {
+          (state.videoElm as any).play();
+        }, 200);
       }
 
       if (props.options.touchPlay) {
@@ -209,7 +214,10 @@ export default create({
         // 播放状态
         if (state.state.playing) {
           try {
-            (state.videoElm as any).play();
+            setTimeout(() => {
+              (state.videoElm as any).play();
+            }, 200);
+
             // 监听缓存进度
             (state.videoElm as any).addEventListener('progress', () => {
               getLoadTime();