Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Commit

Permalink
style(ui/chip): format code
Browse files Browse the repository at this point in the history
  • Loading branch information
haoziqaq committed Feb 18, 2022
1 parent bb0fa3c commit 819fb9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
17 changes: 9 additions & 8 deletions packages/varlet-vue2-ui/src/chip/Chip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,37 @@

<script>
import VarIcon from '../icon'
// import { defineComponent, computed } from 'vue'
import { defineComponent } from '../utils/create'
import { props } from './props'
// import type { ComputedRef } from 'vue'
export default defineComponent({
name: 'VarChip',
components: {
VarIcon,
},
inheritAttrs: false,
props,
computed: {
chipStyles() {
const { plain, textColor, color } = this
if (plain) {
return {
color: textColor || color,
borderColor: color,
}
}
return {
color: textColor,
background: color,
}
},
contentClass() {
const { size, block, type, plain, round } = this
const blockClass = block ? 'var--flex' : 'var--inline-flex'
Expand All @@ -53,13 +57,10 @@ export default defineComponent({
return [`var-chip--${size}`, blockClass, plainTypeClass, roundClass]
},
},
methods: {
onClose(e) {
const { onClose } = this.getListeners()
if (!onClose) {
return
}
onClose(e)
this.getListeners().onClose?.(e)
},
},
})
Expand Down
5 changes: 1 addition & 4 deletions packages/varlet-vue2-ui/src/chip/__tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import Vue from 'vue'
import Chip from '..'
import VarChip from '../Chip'
import { mount } from '@vue/test-utils'
import { createApp } from 'vue'

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

test('test chip plugin', () => {
Expand All @@ -32,7 +31,6 @@ test('test chip close', () => {

const wrapper = mount(VarChip, {
propsData: {
onClose,
closable: true,
},
listeners: {
Expand All @@ -41,7 +39,6 @@ test('test chip close', () => {
})

const closeEl = wrapper.find('.var-chip--close')

expect(closeEl.exists()).toBe(true)
closeEl.trigger('click')
expect(onClose).toHaveBeenCalledTimes(1)
Expand Down

0 comments on commit 819fb9d

Please sign in to comment.