-
-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui/ripple): fix ripple repeat call remove ripple task, ripple uni…
…t test complete affects: @varlet/ui
- Loading branch information
Showing
7 changed files
with
148 additions
and
2 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
46 changes: 46 additions & 0 deletions
46
packages/varlet-ui/src/popup/__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
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
10 changes: 10 additions & 0 deletions
10
packages/varlet-ui/src/ripple/__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,10 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`test ripple example 1`] = ` | ||
"<div class=\\"app-type\\">基本使用</div> | ||
<div class=\\"block var-elevation--2\\">点击</div> | ||
<div class=\\"app-type\\">自定义颜色</div> | ||
<div class=\\"block var-elevation--2\\">点击</div> | ||
<div class=\\"app-type\\">禁用状态</div> | ||
<div class=\\"block var-elevation--2\\">点击</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,74 @@ | ||
import example from '../example' | ||
import Ripple from '..' | ||
import { mount } from '@vue/test-utils' | ||
import { createApp } from 'vue' | ||
import { delay, mockOffset, trigger, triggerDrag } from '../../utils/jest' | ||
|
||
mockOffset() | ||
|
||
test('test ripple example', () => { | ||
const wrapper = mount(example) | ||
expect(wrapper.html()).toMatchSnapshot() | ||
wrapper.unmount() | ||
}) | ||
|
||
test('test ripple plugin', () => { | ||
const app = createApp({}).use(Ripple) | ||
expect(app.directive('ripple')).toBeTruthy() | ||
}) | ||
|
||
const Wrapper = { | ||
directives: { Ripple }, | ||
data: () => ({ | ||
color: 'yellow', | ||
disabled: false, | ||
}), | ||
template: ` | ||
<div class="ripple-container" style="width: 100px; height: 100px" v-ripple="{ color, disabled }"></div> | ||
`, | ||
} | ||
|
||
test('test ripple show & hide', async () => { | ||
const wrapper = mount(Wrapper, { attachTo: document.body }) | ||
await trigger(wrapper, 'touchstart') | ||
await delay(60) | ||
expect(wrapper.find('.var-ripple').exists()).toBeTruthy() | ||
|
||
await trigger(wrapper, 'touchend') | ||
await delay(1000) | ||
expect(wrapper.find('.var-ripple').exists()).toBeFalsy() | ||
wrapper.unmount() | ||
}) | ||
|
||
test('test ripple update & color', async () => { | ||
const wrapper = mount(Wrapper, { attachTo: document.body }) | ||
await wrapper.setData({ color: 'green' }) | ||
|
||
await trigger(wrapper, 'touchstart') | ||
await delay(60) | ||
expect(wrapper.find('.var-ripple').exists()).toBeTruthy() | ||
expect(wrapper.find('.var-ripple').element.style.backgroundColor).toBe('green') | ||
|
||
wrapper.unmount() | ||
}) | ||
|
||
test('test ripple disabled', async () => { | ||
const wrapper = mount(Wrapper, { attachTo: document.body }) | ||
await wrapper.setData({ disabled: true }) | ||
|
||
await trigger(wrapper, 'touchstart') | ||
await delay(60) | ||
expect(wrapper.find('.var-ripple').exists()).toBeFalsy() | ||
|
||
wrapper.unmount() | ||
}) | ||
|
||
test('test ripple touchmove', async () => { | ||
const wrapper = mount(Wrapper, { attachTo: document.body }) | ||
|
||
await triggerDrag(wrapper, 0, 20) | ||
await delay(60) | ||
expect(wrapper.find('.var-ripple').exists()).toBeFalsy() | ||
|
||
wrapper.unmount() | ||
}) |
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