feat: add button group

This commit is contained in:
zazzaz 2020-08-04 11:20:52 +08:00 committed by Herrington Darkholme
parent 9ee4a188e4
commit 277661d9d1
5 changed files with 37 additions and 2 deletions

View File

@ -1,5 +1,6 @@
import { mount } from '@vue/test-utils'
import Button from '../src/index.vue'
import Button from '../src/button.vue'
import ButtonGroup from '../src/button-group.vue'
const AXIOM = 'Rem is the best girl'
const COMMON_CONFIG = {
@ -127,3 +128,21 @@ describe('Button.vue', () => {
})
})
describe('Button Group', () => {
const TestComponent = {
template: `<el-button-group>
<el-button type="primary"></el-button>
<el-button type="primary"></el-button>
</el-button-group>`,
components: {
'el-button-group': ButtonGroup,
'el-button': Button,
},
}
it('create', () => {
const wrapper = mount(TestComponent)
expect(wrapper.classes()).toContain('el-button-group')
expect(wrapper.findAll('button').length).toBe(2)
})
})

View File

@ -4,3 +4,7 @@ export default {
export const NormalButton = (): string => '<el-button>With Text</el-button>'
export const ButtonTwo = (): string => '<el-button>button two</el-button>'
export const ButtonGroup = (): string => `<el-button-group>
<el-button type="primary" icon="el-icon-arrow-left"></el-button>
<el-button type="primary"><i class="el-icon-arrow-right el-icon--right"></i></el-button>
</el-button-group>`

View File

@ -1,6 +1,8 @@
import { App } from 'vue'
import Button from './src/index.vue'
import Button from './src/button.vue'
import ButtonGroup from './src/button-group.vue'
export default (app: App): void => {
app.component(Button.name, Button)
app.component(ButtonGroup.name, ButtonGroup)
}

View File

@ -0,0 +1,10 @@
<template>
<div class="el-button-group">
<slot></slot>
</div>
</template>
<script lang='ts'>
export default {
name: 'ElButtonGroup',
}
</script>