-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,721 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports | ||
const { fs } = require('memfs'); | ||
module.exports = fs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports | ||
const { fs } = require('memfs'); | ||
module.exports = fs.promises; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"@quasar/testing-unit-vitest": { | ||
"options": ["ui"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<template> | ||
<div> | ||
<p>{{ title }}</p> | ||
<q-list> | ||
<q-item v-for="todo in todos" :key="todo.id" clickable @click="increment"> | ||
{{ todo.id }} - {{ todo.content }} | ||
</q-item> | ||
</q-list> | ||
|
||
<p>Count: {{ todoCount }} / {{ meta.totalCount }}</p> | ||
<p>Active: {{ active ? 'yes' : 'no' }}</p> | ||
<p>Clicks on todos: {{ clickCount }}</p> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { computed, ref } from 'vue'; | ||
interface Meta { | ||
totalCount: number; | ||
} | ||
interface Todo { | ||
content: string; | ||
id: number; | ||
} | ||
const props = withDefaults( | ||
defineProps<{ | ||
active?: boolean; | ||
meta: Meta; | ||
title: string; | ||
todos?: Todo[]; | ||
}>(), | ||
{ | ||
todos: () => [], | ||
}, | ||
); | ||
const clickCount = ref(0); | ||
function increment() { | ||
clickCount.value += 1; | ||
return clickCount.value; | ||
} | ||
const todoCount = computed(() => props.todos.length); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<q-header> | ||
<q-toolbar> | ||
<q-toolbar-title>Header</q-toolbar-title> | ||
</q-toolbar> | ||
</q-header> | ||
<q-footer> | ||
<q-toolbar> | ||
<q-toolbar-title>Footer</q-toolbar-title> | ||
</q-toolbar> | ||
</q-footer> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<template> | ||
<q-btn @click="onClick"> Click me! </q-btn> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { Notify } from 'quasar'; | ||
function onClick() { | ||
Notify.create('Hello there!'); | ||
} | ||
</script> |
39 changes: 39 additions & 0 deletions
39
src/components/demo-vitest/__tests__/ExampleComponent.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { installQuasarPlugin } from '@quasar/quasar-app-extension-testing-unit-vitest'; | ||
import { mount } from '@vue/test-utils'; | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import ExampleComponent from './../ExampleComponent.vue'; | ||
|
||
installQuasarPlugin(); | ||
|
||
describe('example Component', () => { | ||
it('should mount component with todos', async () => { | ||
const wrapper = mount(ExampleComponent, { | ||
props: { | ||
meta: { | ||
totalCount: 4, | ||
}, | ||
title: 'Hello', | ||
todos: [ | ||
{ content: 'Hallo', id: 1 }, | ||
{ content: 'Hoi', id: 2 }, | ||
], | ||
}, | ||
}); | ||
expect(wrapper.vm.clickCount).toBe(0); | ||
Check failure on line 23 in src/components/demo-vitest/__tests__/ExampleComponent.test.ts GitHub Actions / build / build (ubuntu-latest)
|
||
await wrapper.find('.q-item').trigger('click'); | ||
expect(wrapper.vm.clickCount).toBe(1); | ||
Check failure on line 25 in src/components/demo-vitest/__tests__/ExampleComponent.test.ts GitHub Actions / build / build (ubuntu-latest)
|
||
}); | ||
|
||
it('should mount component without todos', () => { | ||
const wrapper = mount(ExampleComponent, { | ||
props: { | ||
meta: { | ||
totalCount: 4, | ||
}, | ||
title: 'Hello', | ||
}, | ||
}); | ||
expect(wrapper.findAll('.q-item')).toHaveLength(0); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
src/components/demo-vitest/__tests__/LayoutComponent.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { installQuasarPlugin } from '@quasar/quasar-app-extension-testing-unit-vitest'; | ||
import { mount } from '@vue/test-utils'; | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import LayoutComponent from './../LayoutComponent.vue'; | ||
|
||
installQuasarPlugin(); | ||
|
||
describe('layout example', () => { | ||
it('should mount component properly', () => { | ||
const wrapper = mount(LayoutComponent); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions | ||
expect(wrapper.exists()).to.be.true; | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
src/components/demo-vitest/__tests__/NotifyComponent.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { installQuasarPlugin } from '@quasar/quasar-app-extension-testing-unit-vitest'; | ||
import { mount } from '@vue/test-utils'; | ||
import { Notify } from 'quasar'; | ||
import { describe, expect, it, vi } from 'vitest'; | ||
|
||
import NotifyComponent from './../NotifyComponent.vue'; | ||
|
||
installQuasarPlugin({ plugins: { Notify } }); | ||
|
||
describe('notify example', () => { | ||
it('should call notify on click', async () => { | ||
expect(NotifyComponent).toBeTruthy(); | ||
|
||
const wrapper = mount(NotifyComponent); | ||
const spy = vi.spyOn(Notify, 'create'); | ||
expect(spy).not.toHaveBeenCalled(); | ||
await wrapper.trigger('click'); | ||
expect(spy).toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { jwYeartext } from 'app/test/vitest/mocks/jw'; | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { | ||
fetchAnnouncements, | ||
fetchJwLanguages, | ||
fetchLatestVersion, | ||
fetchYeartext, | ||
} from '../api'; | ||
|
||
describe('fetchJwLanguages', () => { | ||
it('should fetch the jw languages', async () => { | ||
const languages = await fetchJwLanguages('jw.org'); | ||
expect(languages?.length).toBe(2); | ||
}); | ||
}); | ||
|
||
describe('fetchYeartext', () => { | ||
it('should fetch the yeartext', async () => { | ||
const yeartext = await fetchYeartext('E', 'jw.org'); | ||
expect(yeartext.wtlocale).toBe('E'); | ||
expect(yeartext.yeartext).toBe(jwYeartext.content); | ||
}); | ||
}); | ||
|
||
describe('fetchAnnouncements', () => { | ||
it('should fetch the announcements', async () => { | ||
const announcements = await fetchAnnouncements(); | ||
expect(announcements.length).toBe(3); | ||
}); | ||
}); | ||
|
||
describe('fetchLatestVersion', () => { | ||
it('should fetch the latest version', async () => { | ||
const version = await fetchLatestVersion(); | ||
expect(version).toBe('1.2.3'); | ||
}); | ||
}); |
Oops, something went wrong.