Browse Source

feat: 单元测试

yangxiaolu3 3 years ago
parent
commit
6e9e1c11f1
1 changed files with 44 additions and 1 deletions
  1. 44 1
      src/packages/__VUE/comment/__tests__/comment.spec.ts

+ 44 - 1
src/packages/__VUE/comment/__tests__/comment.spec.ts

@@ -1 +1,44 @@
-import { mount } from '@vue/test-utils';
+import { config, mount } from '@vue/test-utils';
+import { nextTick, toRefs, reactive } from 'vue';
+import NutIcon from '../../icon/index.vue';
+import NutRate from '../../rate/index.vue';
+import Comment from '../index.vue';
+// import { Sku as SkuData, Goods } from '../data';
+import CommentData from '../comment_data.json';
+
+beforeAll(() => {
+  config.global.components = {
+    NutIcon,
+    NutRate
+  };
+});
+
+afterAll(() => {
+  config.global.components = {};
+});
+
+test('comment init render', async () => {
+  const wrapper = mount(Comment, {
+    props: {
+      images: CommentData.Comment.images,
+      videos: CommentData.Comment.videos,
+      info: CommentData.Comment.info
+    }
+  });
+  await nextTick();
+  expect(wrapper.find('.nut-comment__main').exists()).toBeTruthy();
+});
+
+test('comment mutli images', async () => {
+  const wrapper = mount(Comment, {
+    props: {
+      headerType: 'complex',
+      imagesRows: 'multi',
+      images: CommentData.Comment.images,
+      videos: CommentData.Comment.videos,
+      info: CommentData.Comment.info
+    }
+  });
+  await nextTick();
+  expect(wrapper.find('.nut-comment-images__mask').exists()).toBeTruthy();
+});