mirror of
https://github.com/chenasraf/nextcloud-forum.git
synced 2026-05-17 17:28:02 +00:00
chore: update gen templates
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
templates/
|
templates/
|
||||||
scaffolds/
|
gen/
|
||||||
|
|||||||
85
gen/component/{{pascalCase name}}.test.ts
Normal file
85
gen/component/{{pascalCase name}}.test.ts
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
// SPDX-FileCopyrightText: Chen Asraf <contact@casraf.dev>
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit tests for {{pascalCase name}} component.
|
||||||
|
*
|
||||||
|
* See src/components/StatusBadge.test.ts for a complete example.
|
||||||
|
*/
|
||||||
|
import { mount } from '@vue/test-utils'
|
||||||
|
import { describe, expect, it, vi } from 'vitest'
|
||||||
|
|
||||||
|
import { createIconMock, nextcloudL10nMock } from '@/test-utils'
|
||||||
|
import {{ pascalCase name }} from './{{pascalCase name}}.vue'
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Mocks - uncomment as needed
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Mock @nextcloud/l10n (if your component uses t() or n())
|
||||||
|
// vi.mock('@nextcloud/l10n', () => nextcloudL10nMock)
|
||||||
|
|
||||||
|
// Mock icon components (adjust path and name as needed)
|
||||||
|
// vi.mock('@icons/Check.vue', () => createIconMock('CheckIcon'))
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Tests
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
describe('{{pascalCase name}}', () => {
|
||||||
|
// Example: Basic rendering
|
||||||
|
// it('renders correctly', () => {
|
||||||
|
// const wrapper = mount({{pascalCase name}})
|
||||||
|
// expect(wrapper.exists()).toBe(true)
|
||||||
|
// })
|
||||||
|
|
||||||
|
// Example: Testing with props
|
||||||
|
// it('renders with props', () => {
|
||||||
|
// const wrapper = mount({{pascalCase name}}, {
|
||||||
|
// props: { title: 'Hello' },
|
||||||
|
// })
|
||||||
|
// expect(wrapper.text()).toContain('Hello')
|
||||||
|
// })
|
||||||
|
|
||||||
|
// Example: Testing CSS classes
|
||||||
|
// it('applies correct CSS class', () => {
|
||||||
|
// const wrapper = mount({{pascalCase name}}, {
|
||||||
|
// props: { variant: 'primary' },
|
||||||
|
// })
|
||||||
|
// expect(wrapper.classes()).toContain('is-primary')
|
||||||
|
// })
|
||||||
|
|
||||||
|
// Example: Testing emitted events
|
||||||
|
// it('emits click event', async () => {
|
||||||
|
// const wrapper = mount({{pascalCase name}})
|
||||||
|
// await wrapper.trigger('click')
|
||||||
|
// expect(wrapper.emitted('click')).toBeTruthy()
|
||||||
|
// })
|
||||||
|
|
||||||
|
// Example: Testing computed properties
|
||||||
|
// it('computes derived value', () => {
|
||||||
|
// const wrapper = mount({{pascalCase name}}, {
|
||||||
|
// props: { count: 5 },
|
||||||
|
// })
|
||||||
|
// const vm = wrapper.vm as InstanceType<typeof {{pascalCase name}}>
|
||||||
|
// expect(vm.doubleCount).toBe(10)
|
||||||
|
// })
|
||||||
|
|
||||||
|
// Example: Testing conditional rendering
|
||||||
|
// it('shows content when condition is met', () => {
|
||||||
|
// const wrapper = mount({{pascalCase name}}, {
|
||||||
|
// props: { showDetails: true },
|
||||||
|
// })
|
||||||
|
// expect(wrapper.find('.details').exists()).toBe(true)
|
||||||
|
// })
|
||||||
|
|
||||||
|
// Example: Testing slots
|
||||||
|
// it('renders slot content', () => {
|
||||||
|
// const wrapper = mount({{pascalCase name}}, {
|
||||||
|
// slots: { default: 'Slot content' },
|
||||||
|
// })
|
||||||
|
// expect(wrapper.text()).toContain('Slot content')
|
||||||
|
// })
|
||||||
|
|
||||||
|
it.todo('add your tests here')
|
||||||
|
})
|
||||||
@@ -40,7 +40,7 @@ class {{pascalCase name}}Mapper extends QBMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $projectId
|
* @param string $id
|
||||||
* @return array<{{pascalCase name}}>
|
* @return array<{{pascalCase name}}>
|
||||||
*/
|
*/
|
||||||
public function findAll(): array {
|
public function findAll(): array {
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ module.exports = () => {
|
|||||||
component: {
|
component: {
|
||||||
templates: ['gen/component'],
|
templates: ['gen/component'],
|
||||||
output: 'src/components',
|
output: 'src/components',
|
||||||
subDir: false,
|
|
||||||
},
|
},
|
||||||
view: {
|
view: {
|
||||||
templates: ['gen/view'],
|
templates: ['gen/view'],
|
||||||
|
|||||||
Reference in New Issue
Block a user