Skip to content

Commit bbcd29e

Browse files
committed
add tests from @sverhoeven's testing branch
1 parent 9c6cb26 commit bbcd29e

7 files changed

Lines changed: 74 additions & 80 deletions

File tree

README.dev.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ To run linting on commit, you can install a git commit hook with
5858
npx husky install
5959
```
6060

61-
## tests
61+
## Tests
6262

63-
We use Jest for unit tests.
63+
We use Jest for unit tests. To run unit tests (`src/**/*.jest.spec.ts`)
6464

6565
You can run the test with
6666

src/pages/Start.jest.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { beforeEach, describe, expect, it } from '@jest/globals'
2+
import { installQuasarPlugin } from '@quasar/quasar-app-extension-testing-unit-jest'
3+
import { shallowMount, VueWrapper } from '@vue/test-utils'
4+
5+
import Start from './Start.vue'
6+
7+
// Specify here Quasar config you'll need to test your component
8+
installQuasarPlugin()
9+
10+
describe('Start', () => {
11+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
12+
let wrapper: VueWrapper<any>
13+
14+
beforeEach(() => {
15+
wrapper = shallowMount(Start)
16+
})
17+
18+
it('should mount without errors', () => {
19+
expect(wrapper).toBeTruthy()
20+
})
21+
})

src/store/step.jest.spec.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { beforeEach, describe, expect, it } from '@jest/globals'
2+
import * as vue from 'vue'
3+
import { useStep } from './step'
4+
5+
describe('useStep', () => {
6+
let step: {
7+
step: vue.ComputedRef<number>;
8+
next: () => void;
9+
previous: () => void;
10+
goto: (newStep: number) => void;
11+
}
12+
13+
beforeEach(() => {
14+
step = useStep()
15+
step.goto(1) // poor mans reset
16+
})
17+
18+
it('should have initial value of 1', () => {
19+
expect(step.step.value).toEqual(1)
20+
})
21+
22+
describe('after next() call', () => {
23+
beforeEach(() => {
24+
step.next()
25+
})
26+
27+
it('should have value of 2', () => {
28+
expect(step.step.value).toEqual(2)
29+
})
30+
31+
describe('after next() call', () => {
32+
beforeEach(() => {
33+
step.next()
34+
})
35+
36+
it('should have value of 3', () => {
37+
expect(step.step.value).toEqual(3)
38+
})
39+
})
40+
41+
describe('after previous() call', () => {
42+
beforeEach(() => {
43+
step.previous()
44+
})
45+
46+
it('should have value of 1', () => {
47+
expect(step.step.value).toEqual(1)
48+
})
49+
})
50+
})
51+
})

test/jest/__tests__/.gitkeep

Whitespace-only changes.

test/jest/__tests__/MyButton.spec.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.

test/jest/__tests__/demo/MyButton.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

test/jest/__tests__/demo/MyButton.vue

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)