diff --git a/exercises/06.arrays/01.solution.key-prop/key.test.ts b/exercises/06.arrays/01.solution.key-prop/key.test.ts new file mode 100644 index 000000000..290084af9 --- /dev/null +++ b/exercises/06.arrays/01.solution.key-prop/key.test.ts @@ -0,0 +1,24 @@ +import { expect, testStep, dtl } from '@epic-web/workshop-utils/test' + +const originalError = console.error +const errors: Array = [] +console.error = (...args: any[]) => { + errors.push(args[0]) + originalError(...args) +} + +import './index.tsx' + +const { screen } = dtl + +await testStep('Wait for Add Item button', async () => { + await screen.findByRole('button', { name: /add item/i }) +}) + +await testStep('Key prop is provided (no console errors)', async () => { + try { + expect(errors).toHaveLength(0) + } finally { + console.error = originalError + } +}) diff --git a/exercises/06.arrays/02.solution.focus-state/key.test.ts b/exercises/06.arrays/02.solution.focus-state/key.test.ts new file mode 100644 index 000000000..853771bf8 --- /dev/null +++ b/exercises/06.arrays/02.solution.focus-state/key.test.ts @@ -0,0 +1,24 @@ +import { expect, testStep, dtl } from '@epic-web/workshop-utils/test' + +const originalError = console.error +const errors: Array = [] +console.error = (...args: any[]) => { + errors.push(args[0]) + originalError(...args) +} + +import './index.tsx' + +const { screen } = dtl + +await testStep('Wait for things to render', async () => { + await screen.findByText('Without a key') +}) + +await testStep('Key prop is provided (no console errors)', async () => { + try { + expect(errors).toHaveLength(0) + } finally { + console.error = originalError + } +}) diff --git a/exercises/06.arrays/03.solution.key-reset/index.test.ts b/exercises/06.arrays/03.solution.key-reset/index.test.ts new file mode 100644 index 000000000..88569ab74 --- /dev/null +++ b/exercises/06.arrays/03.solution.key-reset/index.test.ts @@ -0,0 +1,5 @@ +import { expect, testStep } from '@epic-web/workshop-utils/test' + +await testStep('this is just a demo', () => { + expect(true).toBe(true) +})