浏览代码

feat(icon): test config

richard1015 3 年之前
父节点
当前提交
2660455723

+ 9 - 0
src/packages/__VUE/icon/__tests__/__snapshots__/index.spec.ts.snap

@@ -0,0 +1,9 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render icon dongdong 1`] = `"<i class=\\"nutui-iconfont nut-icon nut-icon-dongdong\\" src=\\"\\"></i>"`;
+
+exports[`should render icon dongdong color 1`] = `"<i class=\\"nutui-iconfont nut-icon nut-icon-dongdong\\" style=\\"color: red;\\" src=\\"\\"></i>"`;
+
+exports[`should render icon dongdong size 1`] = `"<i class=\\"nutui-iconfont nut-icon nut-icon-dongdong\\" style=\\"font-size: 24px; width: 24px; height: 24px;\\" src=\\"\\"></i>"`;
+
+exports[`should render icon image type 1`] = `"<img class=\\"nut-icon__img\\" src=\\"https://img11.360buyimg.com/imagetools/jfs/t1/137646/13/7132/1648/5f4c748bE43da8ddd/a3f06d51dcae7b60.png\\">"`;

+ 45 - 0
src/packages/__VUE/icon/__tests__/index.spec.ts

@@ -0,0 +1,45 @@
+import { config, mount } from '@vue/test-utils';
+import Icon from '../index.vue';
+
+test('should render icon dongdong', async () => {
+  const wrapper = mount(Icon, {
+    props: {
+      name: 'dongdong'
+    }
+  });
+
+  expect(wrapper.html()).toMatchSnapshot();
+});
+test('should render icon image type', async () => {
+  const wrapper = mount(Icon, {
+    props: {
+      name: 'https://img11.360buyimg.com/imagetools/jfs/t1/137646/13/7132/1648/5f4c748bE43da8ddd/a3f06d51dcae7b60.png'
+    }
+  });
+
+  expect(wrapper.html()).toMatchSnapshot();
+});
+
+test('should render icon dongdong color', async () => {
+  const wrapper = mount(Icon, {
+    props: {
+      name: 'dongdong',
+      color: 'red'
+    }
+  });
+
+  expect(wrapper.find<HTMLElement>('.nut-icon-dongdong').element.style.color).toEqual('red');
+  expect(wrapper.html()).toMatchSnapshot();
+});
+
+test('should render icon dongdong size', async () => {
+  const wrapper = mount(Icon, {
+    props: {
+      name: 'dongdong',
+      size: '24'
+    }
+  });
+
+  expect(wrapper.find<HTMLElement>('.nut-icon-dongdong').element.style.fontSize).toEqual('24px');
+  expect(wrapper.html()).toMatchSnapshot();
+});