From 9610fffae1f46b5310754e4a6ab8a19eff0b83da Mon Sep 17 00:00:00 2001 From: Sacha Stafyniak Date: Sun, 3 Nov 2024 22:44:09 +0100 Subject: [PATCH] test: add base avatar tests (#129) --- components/base/BaseAvatar.vue | 2 +- test/components/base/BaseAvatar.spec.ts | 32 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 test/components/base/BaseAvatar.spec.ts diff --git a/components/base/BaseAvatar.vue b/components/base/BaseAvatar.vue index b4abb72..ad09bb9 100644 --- a/components/base/BaseAvatar.vue +++ b/components/base/BaseAvatar.vue @@ -65,7 +65,7 @@ const props = withDefaults( * Defines the color of the avatar * * @since 3.0.0 - * @default 'default' + * @default 'muted' */ color?: | 'white' diff --git a/test/components/base/BaseAvatar.spec.ts b/test/components/base/BaseAvatar.spec.ts new file mode 100644 index 0000000..c15284a --- /dev/null +++ b/test/components/base/BaseAvatar.spec.ts @@ -0,0 +1,32 @@ +import { BaseAvatar } from '#components' +import { mount } from '@vue/test-utils' +import { beforeEach, describe, expect, it } from 'vitest' +import { resetNuiAppConfig } from '../../utils' + +describe('component: BaseAvatar', () => { + describe('rendering', () => { + beforeEach(() => resetNuiAppConfig('BaseAvatar')) + + it('should render with custom app.config', async () => { + // useAppConfig().nui.BaseAvatar!.color = 'primary' + useAppConfig().nui.BaseAvatar!.size = 'xl' + useAppConfig().nui.BaseAvatar!.rounded = 'lg' + + const component = mount(BaseAvatar) + + const wrapper = component.get('.nui-avatar') + // expect(wrapper.classes('nui-avatar-muted')).toBeTruthy() + expect(wrapper.classes('nui-avatar-xl')).toBeTruthy() + expect(wrapper.classes('nui-avatar-rounded-lg')).toBeTruthy() + }) + + it('should render with default app.config', async () => { + const component = mount(BaseAvatar) + + const wrapper = component.get('.nui-avatar') + // expect(wrapper.classes('nui-avatar-muted')).toBeTruthy() + expect(wrapper.classes('nui-avatar-sm')).toBeTruthy() + expect(wrapper.classes('nui-avatar-rounded-full')).toBeTruthy() + }) + }) +})