diff --git a/components/avatar/__tests__/Avatar.test.js b/components/avatar/__tests__/Avatar.test.js new file mode 100644 index 000000000..22f84e51a --- /dev/null +++ b/components/avatar/__tests__/Avatar.test.js @@ -0,0 +1,14 @@ +import { mount } from '@vue/test-utils' +import Avatar from '..' + +describe('Avatar Render', () => { + it('Render long string correctly', () => { + const wrapper = mount(Avatar, { + slots: { + default: 'TestString', + }, + }) + const children = wrapper.findAll('.ant-avatar-string') + expect(children.length).toBe(1) + }) +}) diff --git a/components/badge/__tests__/index.test.js b/components/badge/__tests__/index.test.js new file mode 100644 index 000000000..8d0e860d1 --- /dev/null +++ b/components/badge/__tests__/index.test.js @@ -0,0 +1,21 @@ +import { mount } from '@vue/test-utils' +import Badge from '../index' + +describe('Badge', () => { + test('badge dot not scaling count > 9', () => { + const badge = mount({ + render () { + return + }, + }) + expect(badge.findAll('.ant-card-multiple-words').length).toBe(0) + }) + test('badge dot not showing count == 0', () => { + const badge = mount({ + render () { + return + }, + }) + expect(badge.findAll('.ant-badge-dot').length).toBe(0) + }) +}) diff --git a/components/icon/__tests__/__snapshots__/index.test.js.snap b/components/icon/__tests__/__snapshots__/index.test.js.snap new file mode 100644 index 000000000..9e4b4b34d --- /dev/null +++ b/components/icon/__tests__/__snapshots__/index.test.js.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Icon should render to a 1`] = ``; diff --git a/components/icon/__tests__/index.test.js b/components/icon/__tests__/index.test.js new file mode 100644 index 000000000..ded9afca7 --- /dev/null +++ b/components/icon/__tests__/index.test.js @@ -0,0 +1,13 @@ +import { mount } from '@vue/test-utils' +import Icon from '..' + +describe('Icon', () => { + it('should render to a ', () => { + const wrapper = mount({ + render (h) { + return + }, + }) + expect(wrapper.html()).toMatchSnapshot() + }) +}) diff --git a/components/modal/__tests__/Modal.test.js b/components/modal/__tests__/Modal.test.js new file mode 100644 index 000000000..b0c180f22 --- /dev/null +++ b/components/modal/__tests__/Modal.test.js @@ -0,0 +1,63 @@ +import { mount } from '@vue/test-utils' +import Vue from 'vue' +import Modal from '..' + +const ModalTester = { + props: ['footer', 'visible'], + methods: { + getContainer () { + return this.$refs.container + }, + }, + render () { + const modalProps = { + props: { + ...this.$props, + getContainer: this.getContainer, + }, + } + return ( +
+
+ + Here is content of Modal + +
+ ) + }, +} + +describe('Modal', () => { + it('render correctly', (done) => { + const wrapper = mount( + { + render () { + return + }, + } + ) + expect(wrapper.html()).toMatchSnapshot() + // https://github.com/vuejs/vue-test-utils/issues/624 + const wrapper1 = mount(ModalTester, { + sync: false, + }) + wrapper1.setProps({ visible: true }) + Vue.nextTick(() => { + expect(wrapper1.html()).toMatchSnapshot() + done() + }) + }) + + it('render without footer', () => { + const wrapper = mount( + { + render () { + return + }, + } + ) + expect(wrapper.html()).toMatchSnapshot() + }) +}) diff --git a/components/modal/__tests__/__snapshots__/Modal.test.js.snap b/components/modal/__tests__/__snapshots__/Modal.test.js.snap new file mode 100644 index 000000000..b6d4b6eae --- /dev/null +++ b/components/modal/__tests__/__snapshots__/Modal.test.js.snap @@ -0,0 +1,73 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Modal render correctly 1`] = ` +
+
+
+
+ +
+
+ +
+`; + +exports[`Modal render correctly 2`] = ` +
+
+
+
+ +
+
+ +
+`; + +exports[`Modal render without footer 1`] = ` +
+
+
+
+ +
+
+ +
+`; diff --git a/tests/setup.js b/tests/setup.js index 42fbf73b0..c6a2fab32 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -1,3 +1,5 @@ +// import Vue from 'vue' +// Vue.config.silent = true /* eslint-disable global-require */ if (typeof window !== 'undefined') {