mirror of
https://github.com/chenasraf/nextcloud-autocurrency.git
synced 2026-05-17 17:28:06 +00:00
chore: update gen templates
This commit is contained in:
89
gen/component/{{pascalCase name}}.test.ts
Normal file
89
gen/component/{{pascalCase name}}.test.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
// SPDX-FileCopyrightText: Chen Asraf <contact@casraf.dev>
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
/**
|
||||
* Unit tests for {{pascalCase name}} component.
|
||||
*
|
||||
* Run tests:
|
||||
* pnpm test # watch mode
|
||||
* pnpm test:run # single run
|
||||
*
|
||||
* 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')
|
||||
})
|
||||
@@ -1,3 +1,8 @@
|
||||
<!--
|
||||
SPDX-FileCopyrightText: Chen Asraf <contact@casraf.dev>
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div>{{ startCase name }}</div>
|
||||
</template>
|
||||
|
||||
@@ -24,7 +24,6 @@ class {{pascalCase name}}Mapper extends QBMapper {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws DoesNotExistException
|
||||
*/
|
||||
@@ -41,6 +40,7 @@ class {{pascalCase name}}Mapper extends QBMapper {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @return array<{{pascalCase name}}>
|
||||
*/
|
||||
public function findAll(): array {
|
||||
|
||||
Reference in New Issue
Block a user