Skip to content

Commit

Permalink
refactor(refactor:adjustment unit test): refactor:adjustment unit test
Browse files Browse the repository at this point in the history
affects: @varlet/ui
  • Loading branch information
qytayh authored and BeADre committed Nov 17, 2021
1 parent 53b024d commit 36659a4
Show file tree
Hide file tree
Showing 6 changed files with 229 additions and 213 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

exports[`test col in row 1`] = `
"<div class=\\"var-row var--box\\" style=\\"justify-content: flex-start; align-items: flex-start;\\">
<div class=\\"var-col var--box var-col--span-8 var-col--offset-4\\" style=\\"padding-left: 0px; padding-right: 0px;\\"></div>
<div class=\\"var-col var--box var-col--span-12\\" style=\\"padding-left: 0px; padding-right: 0px;\\"></div>
<div class=\\"var-col var--box var-col--span-8 var-col--offset-4\\" style=\\"padding-left: 0px; padding-right: 0px;\\">1</div>
<div class=\\"var-col var--box var-col--span-12\\" style=\\"padding-left: 0px; padding-right: 0px;\\">2</div>
</div>"
`;
exports[`test col in row 2`] = `
"<div class=\\"var-row var--box\\" style=\\"justify-content: flex-start; align-items: flex-start;\\">
<div class=\\"var-col var--box var-col--span-12\\" style=\\"padding-left: 0px; padding-right: 5px;\\"></div>
<div class=\\"var-col var--box var-col--span-12\\" style=\\"padding-left: 5px; padding-right: 0px;\\"></div>
<div class=\\"var-col var--box var-col--span-12\\" style=\\"padding-left: 0px; padding-right: 0px;\\">1</div>
<div class=\\"var-col var--box var-col--span-12\\" style=\\"padding-left: 0px; padding-right: 0px;\\">2</div>
</div>"
`;
Expand Down
41 changes: 30 additions & 11 deletions packages/varlet-ui/src/row/__tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import VarRow from '../Row'
import Col from '../../col'
import VarCol from '../../col/Col'
import { mount } from '@vue/test-utils'
import { createApp, h } from 'vue'
import { createApp } from 'vue'
import { delay } from '../../utils/jest'


test('test row example', () => {
const wrapper = mount(example)
Expand All @@ -19,7 +21,16 @@ test('test row & col plugin', () => {
})

test('test row flex', async () => {
const wrapper = mount(VarRow)
const template = `<var-row></var-row>`

const wrapper = mount({
components: {
[VarRow.name]: VarRow
},
template,
})

await delay(0)

await wrapper.setProps({ justify: 'flex-start' })
expect(wrapper.html()).toMatchSnapshot()
Expand Down Expand Up @@ -49,7 +60,13 @@ test('test row flex', async () => {
})

test('test row onClick null callback', () => {
const wrapper = mount(VarRow)
const template = `<var-row></var-row>`
const wrapper = mount({
components: {
[VarRow.name]: VarRow
},
template
})
wrapper.trigger('click')
wrapper.unmount()
})
Expand All @@ -68,20 +85,22 @@ test('test row onClick', () => {
})

test('test col in row', async () => {
const template = `
<var-row>
<var-col :span='span' :offset='offset'>1</var-col>
<var-col :span='12'>2</var-col>
</var-row>
`
const wrapper = mount({
data: () => ({
span: 8,
offset: 4,
}),
render() {
return h(
VarRow,
{
gutter: '10px',
},
() => [h(VarCol, { span: this.span, offset: this.offset }), h(VarCol, { span: 12 })]
)
components:{
[VarCol.name]:VarCol,
[VarRow.name]:VarRow
},
template
})
expect(wrapper.html()).toMatchSnapshot()

Expand Down
Loading

0 comments on commit 36659a4

Please sign in to comment.