-
-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui/input select): 修复了input select的label居中问题 完成layout skeleton的单元测试
affects: @varlet/cli, @varlet/ui
- Loading branch information
Showing
14 changed files
with
433 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
packages/varlet-ui/src/row/__tests__/__snapshots__/index.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
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>" | ||
`; | ||
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>" | ||
`; | ||
exports[`test row example 1`] = ` | ||
"<div class=\\"app-type\\">栅格系统</div> | ||
<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 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
</div> | ||
<div class=\\"app-type\\">偏移</div> | ||
<div class=\\"var-row var--box\\" style=\\"justify-content: flex-start; align-items: flex-start;\\"> | ||
<div class=\\"var-col var--box var-col--span-16 var-col--offset-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">offset: 8 span: 16</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
</div> | ||
<div class=\\"app-type\\">对齐</div> | ||
<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 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
</div> | ||
<div class=\\"var-row var--box\\" style=\\"justify-content: center; align-items: flex-start;\\"> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
</div> | ||
<div class=\\"var-row var--box\\" style=\\"justify-content: flex-end; align-items: flex-start;\\"> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
</div> | ||
<div class=\\"var-row var--box\\" style=\\"justify-content: space-around; align-items: flex-start;\\"> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
</div> | ||
<div class=\\"var-row var--box\\" style=\\"justify-content: space-between; align-items: flex-start;\\"> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
</div> | ||
<div class=\\"app-type\\">列间距</div> | ||
<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 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
<div class=\\"var-col var--box var-col--span-8 col\\" style=\\"padding-left: 0px; padding-right: 0px;\\">span: 8</div> | ||
</div>" | ||
`; | ||
exports[`test row flex 1`] = `"<div class=\\"var-row var--box\\" style=\\"justify-content: flex-start; align-items: flex-start;\\"></div>"`; | ||
exports[`test row flex 2`] = `"<div class=\\"var-row var--box\\" style=\\"justify-content: flex-end; align-items: flex-start;\\"></div>"`; | ||
exports[`test row flex 3`] = `"<div class=\\"var-row var--box\\" style=\\"justify-content: center; align-items: flex-start;\\"></div>"`; | ||
exports[`test row flex 4`] = `"<div class=\\"var-row var--box\\" style=\\"justify-content: space-between; align-items: flex-start;\\"></div>"`; | ||
exports[`test row flex 5`] = `"<div class=\\"var-row var--box\\" style=\\"justify-content: space-around; align-items: flex-start;\\"></div>"`; | ||
exports[`test row flex 6`] = `"<div class=\\"var-row var--box\\" style=\\"justify-content: space-around; align-items: flex-start;\\"></div>"`; | ||
exports[`test row flex 7`] = `"<div class=\\"var-row var--box\\" style=\\"justify-content: space-around; align-items: center;\\"></div>"`; | ||
exports[`test row flex 8`] = `"<div class=\\"var-row var--box\\" style=\\"justify-content: space-around; align-items: flex-end;\\"></div>"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import example from '../example' | ||
import Row from '..' | ||
import VarRow from '../Row' | ||
import Col from '../../col' | ||
import VarCol from '../../col/Col' | ||
import { mount } from '@vue/test-utils' | ||
import { createApp, h } from 'vue' | ||
|
||
test('test row example', () => { | ||
const wrapper = mount(example) | ||
expect(wrapper.html()).toMatchSnapshot() | ||
}) | ||
|
||
test('test row plugin', () => { | ||
const app = createApp({}).use(Row) | ||
expect(app.component(Row.name)).toBeTruthy() | ||
}) | ||
|
||
test('test col plugin', () => { | ||
const app = createApp({}).use(Col) | ||
expect(app.component(Col.name)).toBeTruthy() | ||
}) | ||
|
||
test('test row flex', async () => { | ||
const wrapper = mount(VarRow) | ||
|
||
await wrapper.setProps({ justify: 'flex-start' }) | ||
expect(wrapper.html()).toMatchSnapshot() | ||
|
||
await wrapper.setProps({ justify: 'flex-end' }) | ||
expect(wrapper.html()).toMatchSnapshot() | ||
|
||
await wrapper.setProps({ justify: 'center' }) | ||
expect(wrapper.html()).toMatchSnapshot() | ||
|
||
await wrapper.setProps({ justify: 'space-between' }) | ||
expect(wrapper.html()).toMatchSnapshot() | ||
|
||
await wrapper.setProps({ justify: 'space-around' }) | ||
expect(wrapper.html()).toMatchSnapshot() | ||
|
||
await wrapper.setProps({ align: 'flex-start' }) | ||
expect(wrapper.html()).toMatchSnapshot() | ||
|
||
await wrapper.setProps({ align: 'center' }) | ||
expect(wrapper.html()).toMatchSnapshot() | ||
|
||
await wrapper.setProps({ align: 'flex-end' }) | ||
expect(wrapper.html()).toMatchSnapshot() | ||
}) | ||
|
||
test('test row onClick null callback', () => { | ||
const wrapper = mount(VarRow) | ||
wrapper.trigger('click') | ||
}) | ||
|
||
test('test row onClick', () => { | ||
const onClick = jest.fn() | ||
|
||
const wrapper = mount(VarRow, { | ||
props: { | ||
onClick, | ||
}, | ||
}) | ||
wrapper.trigger('click') | ||
expect(onClick).toHaveBeenCalledTimes(1) | ||
}) | ||
|
||
test('test col in row', async () => { | ||
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 })] | ||
) | ||
}, | ||
}) | ||
expect(wrapper.html()).toMatchSnapshot() | ||
|
||
await wrapper.setData({ | ||
span: 12, | ||
offset: 0, | ||
}) | ||
expect(wrapper.html()).toMatchSnapshot() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.