Skip to content

Commit

Permalink
test(ui/button): 更新快照
Browse files Browse the repository at this point in the history
affects: @varlet/cli, @varlet/ui
  • Loading branch information
haoziqaq committed Apr 25, 2021
1 parent 7eba4c9 commit dcd579d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 250 deletions.
3 changes: 1 addition & 2 deletions packages/varlet-cli/src/commands/jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ export async function jest(cmd: { watch: boolean }, args: any) {
rootDir: CWD,
watch: cmd.watch,
config: JEST_CONFIG,
testMatch: Array.isArray(args) ? [`**/${args[0]}/__tests__/*.[jt]s`] : undefined
testMatch: Array.isArray(args) ? [`**/${args[0]}/__tests__/*.[jt]s`] : undefined,
}


await runCLI(config as any, [CWD])
}
Original file line number Diff line number Diff line change
@@ -1,123 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`test button color & textColor 1`] = `
VueWrapper {
"__app": Object {
"_component": Object {
"__emits": Object {},
"__props": Array [
Object {},
Array [],
],
"name": "VTU_ROOT",
"render": [Function],
},
"_container": <div
data-v-app=""
>
<button
class="var-button var--box var-button--normal var--inline-flex var-button--default var-elevation--1"
style="color: rgb(0, 0, 0); background: rgb(0, 0, 0);"
>
<!--v-if-->
<div
class="var-button__content"
>
</div>
</button>
</div>,
"_context": Object {
"app": [Circular],
"components": Object {
"transition": Object {
"name": "transition",
"props": undefined,
"render": [Function],
},
"transition-group": Object {
"name": "transition-group",
"props": undefined,
"render": [Function],
},
},
"config": Object {
"errorHandler": undefined,
"globalProperties": Object {},
"isCustomElement": [Function],
"isNativeTag": [Function],
"optionMergeStrategies": Object {},
"performance": false,
"warnHandler": undefined,
},
"directives": Object {},
"mixins": Array [
Object {
"__emits": null,
"__props": Array [],
"beforeCreate": [Function],
},
],
"provides": Object {},
"reload": [Function],
},
"_props": null,
"_uid": 6,
"component": [Function],
"config": Object {
"errorHandler": undefined,
"globalProperties": Object {},
"isCustomElement": [Function],
"isNativeTag": [Function],
"optionMergeStrategies": Object {},
"performance": false,
"warnHandler": undefined,
},
"directive": [Function],
"mixin": [Function],
"mount": [Function],
"provide": [Function],
"unmount": [Function],
"use": [Function],
"version": "3.0.7",
},
"__setProps": [Function],
"componentVM": Object {
"block": false,
"color": "#000",
"disabled": false,
"handleClick": [Function],
"handleTouchstart": [Function],
"hasOwnProperty": [Function],
"loading": false,
"loadingRadius": 12,
"loadingSize": "normal",
"loadingType": "circle",
"onClick": undefined,
"onTouchstart": undefined,
"outline": false,
"ripple": true,
"round": false,
"size": "normal",
"text": false,
"textColor": "#000",
"type": "default",
},
"rootVM": Object {},
"wrapperElement": <button
class="var-button var--box var-button--normal var--inline-flex var-button--default var-elevation--1"
style="color: rgb(0, 0, 0); background: rgb(0, 0, 0);"
>
<!--v-if-->
<div
class="var-button__content"
>
</div>
</button>,
}
"<button class=\\"var-button var--box var-button--normal var--inline-flex var-button--default var-elevation--1\\" style=\\"color: rgb(0, 0, 0); background: rgb(0, 0, 0);\\">
<!--v-if-->
<div class=\\"var-button__content\\"></div>
</button>"
`;
exports[`test button example 1`] = `
Expand Down Expand Up @@ -268,121 +155,8 @@ exports[`test button example 1`] = `
`;
exports[`test button size & text & block & round 1`] = `
VueWrapper {
"__app": Object {
"_component": Object {
"__emits": Object {},
"__props": Array [
Object {},
Array [],
],
"name": "VTU_ROOT",
"render": [Function],
},
"_container": <div
data-v-app=""
>
<button
class="var-button var--box var-button--large var--flex var-button--text-default var-button--text var-button--round"
style="width: 100%;"
>
<!--v-if-->
<div
class="var-button__content"
>
</div>
</button>
</div>,
"_context": Object {
"app": [Circular],
"components": Object {
"transition": Object {
"name": "transition",
"props": undefined,
"render": [Function],
},
"transition-group": Object {
"name": "transition-group",
"props": undefined,
"render": [Function],
},
},
"config": Object {
"errorHandler": undefined,
"globalProperties": Object {},
"isCustomElement": [Function],
"isNativeTag": [Function],
"optionMergeStrategies": Object {},
"performance": false,
"warnHandler": undefined,
},
"directives": Object {},
"mixins": Array [
Object {
"__emits": null,
"__props": Array [],
"beforeCreate": [Function],
},
],
"provides": Object {},
"reload": [Function],
},
"_props": null,
"_uid": 7,
"component": [Function],
"config": Object {
"errorHandler": undefined,
"globalProperties": Object {},
"isCustomElement": [Function],
"isNativeTag": [Function],
"optionMergeStrategies": Object {},
"performance": false,
"warnHandler": undefined,
},
"directive": [Function],
"mixin": [Function],
"mount": [Function],
"provide": [Function],
"unmount": [Function],
"use": [Function],
"version": "3.0.7",
},
"__setProps": [Function],
"componentVM": Object {
"block": true,
"color": undefined,
"disabled": false,
"handleClick": [Function],
"handleTouchstart": [Function],
"hasOwnProperty": [Function],
"loading": false,
"loadingRadius": 12,
"loadingSize": "normal",
"loadingType": "circle",
"onClick": undefined,
"onTouchstart": undefined,
"outline": false,
"ripple": true,
"round": true,
"size": "large",
"text": true,
"textColor": undefined,
"type": "default",
},
"rootVM": Object {},
"wrapperElement": <button
class="var-button var--box var-button--large var--flex var-button--text-default var-button--text var-button--round"
style="width: 100%;"
>
<!--v-if-->
<div
class="var-button__content"
>
</div>
</button>,
}
"<button class=\\"var-button var--box var-button--large var--flex var-button--text-default var-button--text var-button--round\\" style=\\"width: 100%;\\">
<!--v-if-->
<div class=\\"var-button__content\\"></div>
</button>"
`;
26 changes: 13 additions & 13 deletions packages/varlet-ui/src/button/__tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import VarButton from '../Button'
import { mount } from '@vue/test-utils'
import { createApp } from 'vue'

test('test button example',() => {
test('test button example', () => {
const wrapper = mount(example)
expect(wrapper.html()).toMatchSnapshot()
})

test('test button plugin',() => {
test('test button plugin', () => {
const app = createApp({}).use(Button)
expect(app.component('VarButton')).toBeTruthy()
})
Expand All @@ -20,15 +20,15 @@ test('test button click & touchstart', () => {
wrapper.trigger('touchstart')
})

test('test button onClick & onTouchstart',() => {
test('test button onClick & onTouchstart', () => {
const onClick = jest.fn()
const onTouchstart = jest.fn()

const wrapper = mount(VarButton, {
props: {
onClick,
onTouchstart
}
onTouchstart,
},
})

wrapper.trigger('click')
Expand All @@ -45,8 +45,8 @@ test('test button disabled', () => {
props: {
disabled: true,
onClick,
onTouchstart
}
onTouchstart,
},
})

wrapper.trigger('click')
Expand All @@ -61,8 +61,8 @@ test('test button loading', () => {

const wrapper = mount(VarButton, {
props: {
loading: true
}
loading: true,
},
})

wrapper.trigger('click')
Expand All @@ -76,10 +76,10 @@ test('test button color & textColor', () => {
props: {
color: '#000',
textColor: '#000',
}
},
})

expect(wrapper).toMatchSnapshot()
expect(wrapper.html()).toMatchSnapshot()
})

test('test button size & text & block & round', () => {
Expand All @@ -89,8 +89,8 @@ test('test button size & text & block & round', () => {
round: true,
text: true,
block: true,
}
},
})

expect(wrapper).toMatchSnapshot()
expect(wrapper.html()).toMatchSnapshot()
})
2 changes: 1 addition & 1 deletion packages/varlet-ui/types/dialog.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { App, Component } from 'vue'
import { App } from 'vue'
import { VarComponent } from './varComponent'

interface DialogProps {
Expand Down

0 comments on commit dcd579d

Please sign in to comment.