@userfrosting/theme-pink-cupcake
Version:
Pink Cupcake Theme for UserFrosting
63 lines (56 loc) • 1.92 kB
text/typescript
import { afterEach, beforeEach, expect, test, describe, vi } from 'vitest'
import { mount } from '@vue/test-utils'
import { useConfigStore, usePageMeta } from '@userfrosting/sprinkle-core/stores'
import PageLogin from '../../../views/Account/PageLogin.vue'
// Mock the config and pageMeta store
vi.mock('@userfrosting/sprinkle-core/stores')
const mockUseConfigStore = {
get: vi.fn()
}
const mockUsePageMeta = {
hideTitle: false
}
describe('PageLogin.vue', () => {
afterEach(() => {
vi.clearAllMocks()
vi.resetAllMocks()
})
beforeEach(() => {
mockUseConfigStore.get.mockReturnValue(true)
vi.mocked(useConfigStore).mockReturnValue(mockUseConfigStore as any)
vi.mocked(usePageMeta).mockReturnValue(mockUsePageMeta as any)
})
test('Render correctly', () => {
const wrapper = mount(PageLogin, {
global: {
stubs: [
'router-link',
'UFCardBoxLarge',
'UFCardBoxHalf',
'UFCardBox',
'UFAlert',
'FontAwesomeIcon'
]
}
})
expect(wrapper.exists()).toBe(true)
})
test('gotoVerification is not available if verification is disabled', async () => {
// Custom mock the config store
mockUseConfigStore.get.mockReturnValue(false)
vi.mocked(useConfigStore).mockReturnValue(mockUseConfigStore as any)
const wrapper = mount(PageLogin, {
global: {
stubs: [
'router-link',
'UFCardBoxLarge',
'UFCardBoxHalf',
'UFCardBox',
'UFAlert',
'FontAwesomeIcon'
]
}
})
expect(wrapper.find('[data-test="gotoVerification"]').exists()).toBe(false)
})
})