mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-22 07:19:41 +00:00
Backport of #7305 to `cloud/1.34` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7313-backport-cloud-1-34-style-redesign-TopUpCredits-dialog-2c56d73d36508172b633f5602a8b967d) by [Unito](https://www.unito.io) Co-authored-by: Christian Byrne <cbyrne@comfy.org>
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { mount } from '@vue/test-utils'
|
|
import { createI18n } from 'vue-i18n'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import CreditTopUpOption from '@/components/dialog/content/credit/CreditTopUpOption.vue'
|
|
|
|
const i18n = createI18n({
|
|
legacy: false,
|
|
locale: 'en',
|
|
messages: { en: {} }
|
|
})
|
|
|
|
const mountOption = (
|
|
props?: Partial<{ credits: number; description: string; selected: boolean }>
|
|
) =>
|
|
mount(CreditTopUpOption, {
|
|
props: {
|
|
credits: 1000,
|
|
description: '~100 videos*',
|
|
selected: false,
|
|
...props
|
|
},
|
|
global: {
|
|
plugins: [i18n]
|
|
}
|
|
})
|
|
|
|
describe('CreditTopUpOption', () => {
|
|
it('renders credit amount and description', () => {
|
|
const wrapper = mountOption({ credits: 5000, description: '~500 videos*' })
|
|
expect(wrapper.text()).toContain('5,000')
|
|
expect(wrapper.text()).toContain('~500 videos*')
|
|
})
|
|
|
|
it('applies unselected styling when not selected', () => {
|
|
const wrapper = mountOption({ selected: false })
|
|
expect(wrapper.find('div').classes()).toContain(
|
|
'bg-component-node-disabled'
|
|
)
|
|
expect(wrapper.find('div').classes()).toContain('border-transparent')
|
|
})
|
|
|
|
it('emits select event when clicked', async () => {
|
|
const wrapper = mountOption()
|
|
await wrapper.find('div').trigger('click')
|
|
expect(wrapper.emitted('select')).toHaveLength(1)
|
|
})
|
|
})
|