Skip to content

Commit 4e48844

Browse files
committed
add a few tests
1 parent a06069c commit 4e48844

File tree

10 files changed

+6164
-502
lines changed

10 files changed

+6164
-502
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { expect, testStep, dtl } from '@epic-web/workshop-utils/test'
2+
const { screen, fireEvent } = dtl
3+
4+
import './index.tsx'
5+
6+
await testStep('The user can see the counter', async () => {
7+
const output = await screen.findByRole('status')
8+
expect(output).toHaveTextContent('0')
9+
})
10+
11+
const incrementButton = await testStep(
12+
'The user can see the increment button',
13+
async () => {
14+
const result = await screen.findByRole('button', { name: '➡️' })
15+
return result
16+
},
17+
)
18+
19+
const decrementButton = await testStep(
20+
'The user can see the decrement button',
21+
async () => {
22+
const result = await screen.findByRole('button', { name: '⬅️' })
23+
return result
24+
},
25+
)
26+
27+
await testStep('The user can increment the counter', async () => {
28+
fireEvent.click(incrementButton)
29+
const output = await screen.findByRole('status')
30+
expect(output).toHaveTextContent('1')
31+
})
32+
33+
await testStep('The user can decrement the counter', async () => {
34+
fireEvent.click(decrementButton)
35+
const output = await screen.findByRole('status')
36+
expect(output).toHaveTextContent('0')
37+
})
38+
39+
const stepInput = await testStep(
40+
'The user can see the step input',
41+
async () => {
42+
const result = await screen.findByLabelText(/step/i)
43+
expect(result).toHaveValue(1)
44+
return result
45+
},
46+
)
47+
48+
await testStep('The user can change the step value', async () => {
49+
fireEvent.change(stepInput, { target: { value: '5' } })
50+
expect(stepInput).toHaveValue(5)
51+
})
52+
53+
await testStep(
54+
'Changing step value affects increment and decrement',
55+
async () => {
56+
fireEvent.click(incrementButton)
57+
let output = await screen.findByRole('status')
58+
expect(output).toHaveTextContent('5')
59+
60+
fireEvent.click(decrementButton)
61+
output = await screen.findByRole('status')
62+
expect(output).toHaveTextContent('0')
63+
},
64+
)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { expect, testStep, dtl } from '@epic-web/workshop-utils/test'
2+
const { screen, fireEvent } = dtl
3+
4+
import './index.tsx'
5+
6+
await testStep('The user can see the counter', async () => {
7+
const output = await screen.findByRole('status')
8+
expect(output).toHaveTextContent('0')
9+
})
10+
11+
const incrementButton = await testStep(
12+
'The user can see the increment button',
13+
async () => {
14+
const result = await screen.findByRole('button', { name: '➡️' })
15+
return result
16+
},
17+
)
18+
19+
const decrementButton = await testStep(
20+
'The user can see the decrement button',
21+
async () => {
22+
const result = await screen.findByRole('button', { name: '⬅️' })
23+
return result
24+
},
25+
)
26+
27+
await testStep('The user can increment the counter', async () => {
28+
fireEvent.click(incrementButton)
29+
const output = await screen.findByRole('status')
30+
expect(output).toHaveTextContent('1')
31+
})
32+
33+
await testStep('The user can decrement the counter', async () => {
34+
fireEvent.click(decrementButton)
35+
const output = await screen.findByRole('status')
36+
expect(output).toHaveTextContent('0')
37+
})
38+
39+
const stepInput = await testStep(
40+
'The user can see the step input',
41+
async () => {
42+
const result = await screen.findByLabelText(/step/i)
43+
expect(result).toHaveValue(1)
44+
return result
45+
},
46+
)
47+
48+
await testStep('The user can change the step value', async () => {
49+
fireEvent.change(stepInput, { target: { value: '5' } })
50+
expect(stepInput).toHaveValue(5)
51+
})
52+
53+
await testStep(
54+
'Changing step value affects increment and decrement',
55+
async () => {
56+
fireEvent.click(incrementButton)
57+
let output = await screen.findByRole('status')
58+
expect(output).toHaveTextContent('5')
59+
60+
fireEvent.click(decrementButton)
61+
output = await screen.findByRole('status')
62+
expect(output).toHaveTextContent('0')
63+
},
64+
)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { expect, testStep, dtl } from '@epic-web/workshop-utils/test'
2+
const { screen, fireEvent } = dtl
3+
4+
import './index.tsx'
5+
6+
await testStep('The user can see the counter', async () => {
7+
const output = await screen.findByRole('status')
8+
expect(output).toHaveTextContent('0')
9+
})
10+
11+
const incrementButton = await testStep(
12+
'The user can see the increment button',
13+
async () => {
14+
const result = await screen.findByRole('button', { name: '➡️' })
15+
return result
16+
},
17+
)
18+
19+
const decrementButton = await testStep(
20+
'The user can see the decrement button',
21+
async () => {
22+
const result = await screen.findByRole('button', { name: '⬅️' })
23+
return result
24+
},
25+
)
26+
27+
await testStep('The user can increment the counter', async () => {
28+
fireEvent.click(incrementButton)
29+
const output = await screen.findByRole('status')
30+
expect(output).toHaveTextContent('1')
31+
})
32+
33+
await testStep('The user can decrement the counter', async () => {
34+
fireEvent.click(decrementButton)
35+
const output = await screen.findByRole('status')
36+
expect(output).toHaveTextContent('0')
37+
})
38+
39+
const stepInput = await testStep(
40+
'The user can see the step input',
41+
async () => {
42+
const result = await screen.findByLabelText(/step/i)
43+
expect(result).toHaveValue(1)
44+
return result
45+
},
46+
)
47+
48+
await testStep('The user can change the step value', async () => {
49+
fireEvent.change(stepInput, { target: { value: '5' } })
50+
expect(stepInput).toHaveValue(5)
51+
})
52+
53+
await testStep(
54+
'Changing step value affects increment and decrement',
55+
async () => {
56+
fireEvent.click(incrementButton)
57+
let output = await screen.findByRole('status')
58+
expect(output).toHaveTextContent('5')
59+
60+
fireEvent.click(decrementButton)
61+
output = await screen.findByRole('status')
62+
expect(output).toHaveTextContent('0')
63+
},
64+
)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { expect, testStep, dtl } from '@epic-web/workshop-utils/test'
2+
const { screen, fireEvent } = dtl
3+
4+
import './index.tsx'
5+
6+
await testStep('The user can see the counter', async () => {
7+
const output = await screen.findByRole('status')
8+
expect(output).toHaveTextContent('0')
9+
})
10+
11+
const incrementButton = await testStep(
12+
'The user can see the increment button',
13+
async () => {
14+
const result = await screen.findByRole('button', { name: '➡️' })
15+
return result
16+
},
17+
)
18+
19+
const decrementButton = await testStep(
20+
'The user can see the decrement button',
21+
async () => {
22+
const result = await screen.findByRole('button', { name: '⬅️' })
23+
return result
24+
},
25+
)
26+
27+
await testStep('The user can increment the counter', async () => {
28+
fireEvent.click(incrementButton)
29+
const output = await screen.findByRole('status')
30+
expect(output).toHaveTextContent('1')
31+
})
32+
33+
await testStep('The user can decrement the counter', async () => {
34+
fireEvent.click(decrementButton)
35+
const output = await screen.findByRole('status')
36+
expect(output).toHaveTextContent('0')
37+
})
38+
39+
const stepInput = await testStep(
40+
'The user can see the step input',
41+
async () => {
42+
const result = await screen.findByLabelText(/step/i)
43+
expect(result).toHaveValue(1)
44+
return result
45+
},
46+
)
47+
48+
await testStep('The user can change the step value', async () => {
49+
fireEvent.change(stepInput, { target: { value: '5' } })
50+
expect(stepInput).toHaveValue(5)
51+
})
52+
53+
await testStep(
54+
'Changing step value affects increment and decrement',
55+
async () => {
56+
fireEvent.click(incrementButton)
57+
let output = await screen.findByRole('status')
58+
expect(output).toHaveTextContent('5')
59+
60+
fireEvent.click(decrementButton)
61+
output = await screen.findByRole('status')
62+
expect(output).toHaveTextContent('0')
63+
},
64+
)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { expect, testStep, dtl } from '@epic-web/workshop-utils/test'
2+
const { screen, fireEvent } = dtl
3+
4+
import './index.tsx'
5+
6+
await testStep('The user can see the counter', async () => {
7+
const output = await screen.findByRole('status')
8+
expect(output).toHaveTextContent('0')
9+
})
10+
11+
const incrementButton = await testStep(
12+
'The user can see the increment button',
13+
async () => {
14+
const result = await screen.findByRole('button', { name: '➡️' })
15+
return result
16+
},
17+
)
18+
19+
const decrementButton = await testStep(
20+
'The user can see the decrement button',
21+
async () => {
22+
const result = await screen.findByRole('button', { name: '⬅️' })
23+
return result
24+
},
25+
)
26+
27+
await testStep('The user can increment the counter', async () => {
28+
fireEvent.click(incrementButton)
29+
const output = await screen.findByRole('status')
30+
expect(output).toHaveTextContent('1')
31+
})
32+
33+
await testStep('The user can decrement the counter', async () => {
34+
fireEvent.click(decrementButton)
35+
const output = await screen.findByRole('status')
36+
expect(output).toHaveTextContent('0')
37+
})
38+
39+
const stepInput = await testStep(
40+
'The user can see the step input',
41+
async () => {
42+
const result = await screen.findByLabelText(/step/i)
43+
expect(result).toHaveValue(1)
44+
return result
45+
},
46+
)
47+
48+
await testStep('The user can change the step value', async () => {
49+
fireEvent.change(stepInput, { target: { value: '5' } })
50+
expect(stepInput).toHaveValue(5)
51+
})
52+
53+
await testStep(
54+
'Changing step value affects increment and decrement',
55+
async () => {
56+
fireEvent.click(incrementButton)
57+
let output = await screen.findByRole('status')
58+
expect(output).toHaveTextContent('5')
59+
60+
fireEvent.click(decrementButton)
61+
output = await screen.findByRole('status')
62+
expect(output).toHaveTextContent('0')
63+
},
64+
)

0 commit comments

Comments
 (0)