-
Notifications
You must be signed in to change notification settings - Fork 834
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(skeleton): move to script setup (#3007)
- Loading branch information
Showing
32 changed files
with
378 additions
and
382 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -729,6 +729,7 @@ | |
"name": "Skeleton", | ||
"cName": "骨架屏", | ||
"desc": "骨架屏", | ||
"setup": true, | ||
"author": "liqiong" | ||
}, | ||
{ | ||
|
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
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
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
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
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
20 changes: 0 additions & 20 deletions
20
src/packages/__VUE/skeleton/__tests__/__snapshots__/skeleton.spec.ts.snap
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
src/packages/__VUE/skeleton/__tests__/__snapshots__/skeleton.spec.tsx.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,3 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Skeleton: should change avatar shape when using avatarShape prop 1`] = `"<view style="width: 50px; height: 50px; background-color: #eee; color: #666;" class="nut-avatar nut-avatar-normal nut-avatar-square avatarClass avatarClass--square"></view>"`; |
This file was deleted.
Oops, something went wrong.
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,66 @@ | ||
import { mount } from '@vue/test-utils' | ||
import { Skeleton } from '@nutui/nutui' | ||
|
||
test('Skeleton: should render with row‘s father content width correctly', () => { | ||
const wrapper = mount(() => { | ||
return <Skeleton width="100px" /> | ||
}) | ||
const skeleton = wrapper.find('.nut-skeleton-content__line') | ||
expect(skeleton.attributes('style')).includes('width: 100px') | ||
}) | ||
|
||
test('Skeleton: should allow to disable animation', async () => { | ||
const wrapper = mount(() => { | ||
return <Skeleton row={1} /> | ||
}) | ||
|
||
expect(wrapper.find('.nut-skeleton').exists()).toBeTruthy() | ||
|
||
await wrapper.setProps({ animated: false }) | ||
expect(wrapper.find('.skeleton-animation').exists()).toBeFalsy() | ||
}) | ||
|
||
test('Skeleton: should change avatar size when using avatarSize prop', () => { | ||
const wrapper = mount(() => { | ||
return <Skeleton avatar avatarSize="20px" /> | ||
}) | ||
|
||
const avatar = wrapper.find('.avatarClass') | ||
expect(avatar.attributes('style')).includes('width: 20px') | ||
expect(avatar.attributes('style')).includes('height: 20px') | ||
}) | ||
|
||
test('Skeleton: should change avatar shape when using avatarShape prop', () => { | ||
const wrapper = mount(() => { | ||
return <Skeleton avatar avatarShape="square" /> | ||
}) | ||
expect(wrapper.find('.avatarClass').html()).toMatchSnapshot() | ||
}) | ||
|
||
test('Skeleton: should be round when using round prop', () => { | ||
const wrapper = mount(() => { | ||
return <Skeleton title round avatar /> | ||
}) | ||
expect(wrapper.find('.avatarClass').exists()).toBeTruthy() | ||
}) | ||
|
||
test('Skeleton: should render default slot', () => { | ||
const wrapper = mount(() => { | ||
return ( | ||
<Skeleton loading={false}> | ||
content | ||
</Skeleton> | ||
) | ||
}) | ||
expect(wrapper.html()).includes('content') | ||
}) | ||
|
||
test('Skeleton: should render correctly when title uses false', () => { | ||
const wrapper = mount(() => { | ||
return <Skeleton title={false} row={1} /> | ||
}) | ||
const content = wrapper.find('.nut-skeleton-content__line') | ||
|
||
expect(content.find('.nut-skeleton-blockTitle').exists()).toBeFalsy() | ||
expect(content.findAll('.nut-skeleton-blockLine').length).toBe(1) | ||
}) |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Skeleton from './skeleton.taro.vue' | ||
import type { ComponentPublicInstance } from 'vue' | ||
import { withInstall } from '@/packages/utils' | ||
|
||
withInstall(Skeleton) | ||
|
||
export type { SkeletonProps } from './skeleton.taro.vue' | ||
|
||
export type SkeletonInstance = ComponentPublicInstance & InstanceType<typeof Skeleton> | ||
|
||
export { Skeleton, Skeleton as default } |
Oops, something went wrong.