-
Notifications
You must be signed in to change notification settings - Fork 0
Add tests for skeleton partial components #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { mount } from '@vue/test-utils'; | ||
| import { describe, it, expect } from 'vitest'; | ||
| import ArticleItemSkeletonPartial from '@partials/ArticleItemSkeletonPartial.vue'; | ||
|
|
||
| describe('ArticleItemSkeletonPartial', () => { | ||
| it('is animated by default', () => { | ||
| const wrapper = mount(ArticleItemSkeletonPartial); | ||
|
|
||
| expect(wrapper.attributes('class')).toContain('animate-pulse'); | ||
|
Check failure on line 9 in tests/partials/ArticleItemSkeletonPartial.test.ts
|
||
| }); | ||
|
|
||
| it('can disable the animation', () => { | ||
| const wrapper = mount(ArticleItemSkeletonPartial, { | ||
| props: { isAnimated: false }, | ||
| }); | ||
|
|
||
| expect(wrapper.attributes('class')).not.toContain('animate-pulse'); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { mount } from '@vue/test-utils'; | ||
| import { describe, it, expect } from 'vitest'; | ||
| import PostPageSkeletonPartial from '@partials/PostPageSkeletonPartial.vue'; | ||
|
|
||
| describe('PostPageSkeletonPartial', () => { | ||
| it('exposes a stable test id', () => { | ||
| const wrapper = mount(PostPageSkeletonPartial); | ||
|
|
||
| const root = wrapper.get('[data-testid="post-page-skeleton"]'); | ||
| expect(root.exists()).toBe(true); | ||
| }); | ||
|
|
||
| it('is identified as non-interactive placeholder', () => { | ||
| const wrapper = mount(PostPageSkeletonPartial); | ||
|
|
||
| expect(wrapper.attributes('aria-hidden')).toBe('true'); | ||
| expect(wrapper.attributes('class')).toContain('animate-pulse'); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | ||||||||||||||||||
| import { mount } from '@vue/test-utils'; | ||||||||||||||||||
| import { describe, it, expect } from 'vitest'; | ||||||||||||||||||
| import ProjectCardSkeletonPartial from '@partials/ProjectCardSkeletonPartial.vue'; | ||||||||||||||||||
|
|
||||||||||||||||||
| describe('ProjectCardSkeletonPartial', () => { | ||||||||||||||||||
| it('renders animated wrapper by default', () => { | ||||||||||||||||||
| const wrapper = mount(ProjectCardSkeletonPartial); | ||||||||||||||||||
|
|
||||||||||||||||||
| expect(wrapper.attributes('class')).toContain('animate-pulse'); | ||||||||||||||||||
|
Check failure on line 9 in tests/partials/ProjectCardSkeletonPartial.test.ts
|
||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
| it('merges custom wrapper classes', () => { | ||||||||||||||||||
| const wrapper = mount(ProjectCardSkeletonPartial, { | ||||||||||||||||||
| props: { wrapperClass: 'custom-class' }, | ||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
| expect(wrapper.classes()).toContain('custom-class'); | ||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
| it('disables animation when requested', () => { | ||||||||||||||||||
| const wrapper = mount(ProjectCardSkeletonPartial, { | ||||||||||||||||||
| props: { isAnimated: false }, | ||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
| expect(wrapper.attributes('class')).not.toContain('animate-pulse'); | ||||||||||||||||||
| }); | ||||||||||||||||||
| }); | ||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test suite is missing a check for accessibility. Skeleton loaders are purely decorative and should be hidden from assistive technologies using
Suggested change
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { mount } from '@vue/test-utils'; | ||
| import { describe, it, expect } from 'vitest'; | ||
| import TalkCardSkeletonPartial from '@partials/TalkCardSkeletonPartial.vue'; | ||
|
|
||
| describe('TalkCardSkeletonPartial', () => { | ||
| it('applies animation by default', () => { | ||
| const wrapper = mount(TalkCardSkeletonPartial); | ||
|
|
||
| expect(wrapper.attributes('class')).toContain('animate-pulse'); | ||
|
Check failure on line 9 in tests/partials/TalkCardSkeletonPartial.test.ts
|
||
| expect(wrapper.attributes('aria-hidden')).toBe('true'); | ||
| }); | ||
|
|
||
| it('respects disabled animation flag', () => { | ||
| const wrapper = mount(TalkCardSkeletonPartial, { | ||
| props: { isAnimated: false }, | ||
| }); | ||
|
|
||
| expect(wrapper.attributes('class')).not.toContain('animate-pulse'); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { mount } from '@vue/test-utils'; | ||
| import { describe, it, expect } from 'vitest'; | ||
| import WidgetSkillsSkeletonPartial from '@partials/WidgetSkillsSkeletonPartial.vue'; | ||
|
|
||
| describe('WidgetSkillsSkeletonPartial', () => { | ||
| it('renders six placeholder skill rows', () => { | ||
| const wrapper = mount(WidgetSkillsSkeletonPartial); | ||
| const items = wrapper.findAll('li'); | ||
|
|
||
| expect(items).toHaveLength(6); | ||
| items.forEach((item) => { | ||
| expect(item.classes()).toContain('flex'); | ||
| }); | ||
| }); | ||
|
|
||
| it('is marked as purely decorative', () => { | ||
| const wrapper = mount(WidgetSkillsSkeletonPartial); | ||
|
|
||
| expect(wrapper.attributes('aria-hidden')).toBeUndefined(); | ||
| expect(wrapper.attributes('class')).toContain('animate-pulse'); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
wrapper.get()method throws an error if the element is not found, making thisexpectassertion redundant. The test's purpose is fulfilled byget()succeeding. You can remove this line for a more concise test.