Skip to content

Commit

Permalink
feat: add dashed and rightIcon, and changed fill default value as out…
Browse files Browse the repository at this point in the history
…line (#1695)
  • Loading branch information
xiaoyatong authored Nov 29, 2023
1 parent 50e8cca commit 97da9cc
Show file tree
Hide file tree
Showing 12 changed files with 1,091 additions and 429 deletions.
3 changes: 3 additions & 0 deletions migrate-from-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ plugins: [
#### Button
- 移除 `plain`,通过 `fill="outline"` 实现
- 增加 `ref`,对外暴露组件内 `button` 元素
- 增加 `fill` 模式类型,`dashed`,修改 `fill` 默认值为 `outline`
- 增加 `rightIcon`,可满足同时设置左右两个icon的情况。
- 修改 `size``large` 时的默认 `width``100%` 的值,如果使用通栏的 `button`,可搭配 `block` 来使用。

#### Cell
- `subTitle` 重命名为 `description`,类型修改为 `React.Node`
Expand Down
38 changes: 37 additions & 1 deletion src/packages/button/__test__/button.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react'
// import * as renderer from 'react-test-renderer'

import { render, fireEvent } from '@testing-library/react'
import '@testing-library/jest-dom'

import { useState } from 'react'
import { Star } from '@nutui/icons-react'
import { Button } from '../button'

test('should match snapshot', () => {
Expand All @@ -17,6 +17,42 @@ test('should match snapshot', () => {
expect(container).toMatchSnapshot()
})

test('should fill is outline', () => {
const { getByTestId } = render(
<Button data-testid="button" type="primary" fill="outline">
主要按钮
</Button>
)
expect(getByTestId('button')).toHaveClass('nut-button--outline')
})

test('should have righticon correctly', () => {
const { getByText } = render(
<Button data-testid="button" icon={<Star />} rightIcon={<Star />}>
主要按钮
</Button>
)
expect(getByText('主要按钮')).toHaveClass('right')
})

test('should props color when use fill correctly', () => {
const { getByTestId } = render(
<Button data-testid="button" color="blue" fill="outline">
主要按钮
</Button>
)
expect(getByTestId('button')).toHaveStyle({ 'border-color': 'blue' })
})

test('should props color with no fill correctly', () => {
const { getByTestId } = render(
<Button data-testid="button" color="blue">
主要按钮
</Button>
)
expect(getByTestId('button')).toHaveStyle({ background: 'blue' })
})

test('should children correctly', () => {
const { getByText, getByTestId } = render(
<Button
Expand Down
Loading

0 comments on commit 97da9cc

Please sign in to comment.