Browse Source

test: cell单元测试

zongyue3 4 years ago
parent
commit
36cb86621f
1 changed files with 42 additions and 0 deletions
  1. 42 0
      src/packages/__VUE/cell/__tests__/cell.spec.ts

+ 42 - 0
src/packages/__VUE/cell/__tests__/cell.spec.ts

@@ -0,0 +1,42 @@
+import { mount } from '@vue/test-utils';
+import Cell from '../index.vue';
+
+test('prop title desc', () => {
+  const wrapper = mount(Cell, {
+    props: {
+      title: '标题1',
+      desc: '描述1'
+    }
+  });
+
+  expect(wrapper.html()).toContain('标题1');
+  expect(wrapper.html()).toContain('描述1');
+});
+
+test('prop title subtitle', () => {
+  const wrapper = mount(Cell, {
+    props: {
+      title: '标题1',
+      subTitle: '副标题1'
+    }
+  });
+
+  expect(wrapper.html()).toContain('标题1');
+  expect(wrapper.html()).toContain('副标题1');
+});
+
+test('emit click event', () => {
+  const wrapper = mount(Cell);
+
+  wrapper.trigger('click');
+  expect(wrapper.emitted('click')!.length).toEqual(1);
+});
+
+test('slot test', () => {
+  const wrapper = mount(Cell, {
+    slots: {
+      default: '自定义内容'
+    }
+  });
+  expect(wrapper.html()).toContain('自定义内容');
+});