Skip to content
This repository has been archived by the owner on Oct 27, 2021. It is now read-only.

Commit

Permalink
test(fab): 新增 fab 测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
psaren committed May 30, 2020
1 parent 53b5d3c commit 460d002
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/unit/__snapshots__/fab.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AtFab Event AtFab onClick 1`] = `
<view
class="at-fab at-fab--normal"
onClick="function () {
return fn.apply(this, arguments);
}"
>
按钮
</view>
`;

exports[`AtFab Snap render AtFab -- default props 1`] = `
<view
class="at-fab at-fab--normal"
>
按钮
</view>
`;

exports[`AtFab Snap render AtFab -- props className 1`] = `
<view
class="at-fab button at-fab--normal"
>
按钮
</view>
`;

exports[`AtFab Snap render AtFab -- props size small 1`] = `
<view
class="at-fab at-fab--small"
>
按钮
</view>
`;
36 changes: 36 additions & 0 deletions tests/unit/fab.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { mount } from '@vue/test-utils'
import AtFab from '../../src/components/fab'

const factory = (values = {}, slots = { default: ['按钮'] }) => {
return mount(AtFab, {
components: {},
slots,
propsData: { ...values },
})
}

describe('AtFab Snap', () => {
it('render AtFab -- default props', () => {
const wrapper = factory()
expect(wrapper.element).toMatchSnapshot()
})

it('render AtFab -- props className', () => {
const wrapper = factory({ className: 'button' })
expect(wrapper.element).toMatchSnapshot()
})

it('render AtFab -- props size small', () => {
const wrapper = factory({ size: 'small' })
expect(wrapper.element).toMatchSnapshot()
})
})

describe('AtFab Event', () => {
it('AtFab onClick', () => {
const onClick = jest.fn()
const wrapper = factory({ onClick: onClick })
wrapper.find('.at-fab').trigger('tap')
expect(wrapper.element).toMatchSnapshot()
})
})

0 comments on commit 460d002

Please sign in to comment.