From 9a97c2b25060b0cb80484f0cb967dad58b6fcc0b Mon Sep 17 00:00:00 2001 From: BeADre Date: Wed, 28 Apr 2021 23:13:12 +0800 Subject: [PATCH] test(cell): add test case --- .../__snapshots__/index.spec.js.snap | 91 +++++++++++++++++++ .../src/cell/__tests__/index.spec.js | 37 ++++++++ 2 files changed, 128 insertions(+) create mode 100644 packages/varlet-ui/src/cell/__tests__/__snapshots__/index.spec.js.snap create mode 100644 packages/varlet-ui/src/cell/__tests__/index.spec.js diff --git a/packages/varlet-ui/src/cell/__tests__/__snapshots__/index.spec.js.snap b/packages/varlet-ui/src/cell/__tests__/__snapshots__/index.spec.js.snap new file mode 100644 index 00000000000..e22fbc3a835 --- /dev/null +++ b/packages/varlet-ui/src/cell/__tests__/__snapshots__/index.spec.js.snap @@ -0,0 +1,91 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`test cell example 1`] = ` +"
+
基本使用
+
+ +
+
这是单元格
+ +
+ +
+
+ +
+
这是单元格
+ +
+ +
+
+
+
显示图标
+
+
+
+
这是单元格
+ +
+
+
+
+
+
+
这是单元格
+ +
+
+
+
+
+
显示描述
+
+
+
+
这是单元格
+
描述
+
+
+
+
+ +
+
这是单元格
+
描述
+
+ +
+
+
+
显示边框
+
+ +
+
这是单元格
+ +
+ +
+
+ +
+
这是单元格
+ +
+ +
+
" +`; + +exports[`test cell props 1`] = ` +"
+
+
+
This is Cell
+
This is desc
+
+
text
+
" +`; diff --git a/packages/varlet-ui/src/cell/__tests__/index.spec.js b/packages/varlet-ui/src/cell/__tests__/index.spec.js new file mode 100644 index 00000000000..72264b425f5 --- /dev/null +++ b/packages/varlet-ui/src/cell/__tests__/index.spec.js @@ -0,0 +1,37 @@ +import example from '../example' +import Cell from '..' +import VarCell from '../Cell' +import { mount } from '@vue/test-utils' +import { createApp } from 'vue' + +test('test cell example', () => { + const wrapper = mount(example) + + expect(wrapper.html()).toMatchSnapshot() +}) + +test('test cell plugin', () => { + const app = createApp({}).use(Cell) + expect(app.component(Cell.name)).toBeTruthy() +}) + +test('test cell props', async () => { + const wrapper = mount(VarCell, { + props: { + title: 'This is Cell', + desc: 'This is desc', + border: true, + iconClass: 'test-icon-class', + titleClass: 'test-title-class', + descClass: 'test-desc-class', + extraClass: 'test-extra-class', + icon: 'fire' + }, + slots: { + extra: () => 'text' + } + }) + + + expect(wrapper.html()).toMatchSnapshot() +})