From 5c30249fb470f780e90afa805c8adf2c3339a386 Mon Sep 17 00:00:00 2001 From: ThomasL Date: Thu, 13 Jul 2023 15:28:13 +0200 Subject: [PATCH] refactor(challenge19): clarify test --- .../src/app/counter.component.cy.ts | 12 ++++++---- .../src/app/counter.component.spec.ts | 23 +++++++++++++++++-- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/apps/testing-input-output/src/app/counter.component.cy.ts b/apps/testing-input-output/src/app/counter.component.cy.ts index 8435c98..484ec5a 100644 --- a/apps/testing-input-output/src/app/counter.component.cy.ts +++ b/apps/testing-input-output/src/app/counter.component.cy.ts @@ -1,11 +1,13 @@ import { CounterComponent } from './counter.component'; describe(CounterComponent.name, () => { - it('using createOutputSpy', () => { - cy.mount(CounterComponent); - }); + describe('Given an initualValue of 10', async () => { + it('listen to output using createOutputSpy', () => { + cy.mount(CounterComponent); + }); - it('using autoSpyOutputs', () => { - cy.mount(CounterComponent); + it('listen to output using autoSpyOutputs', () => { + cy.mount(CounterComponent); + }); }); }); diff --git a/apps/testing-input-output/src/app/counter.component.spec.ts b/apps/testing-input-output/src/app/counter.component.spec.ts index 3cac547..dd8c08d 100644 --- a/apps/testing-input-output/src/app/counter.component.spec.ts +++ b/apps/testing-input-output/src/app/counter.component.spec.ts @@ -2,7 +2,26 @@ import { render } from '@testing-library/angular'; import { CounterComponent } from './counter.component'; describe('CounterComponent', () => { - test('set input and listen to output', async () => { - await render(CounterComponent); + describe('Given an initualValue of 10', async () => { + test('Then counterValue is 10', async () => { + await render(CounterComponent); + }); + + describe('When clicking 5 times on increment button', async () => { + test('Then counterValue is 15', async () => { + await render(CounterComponent); + }); + }); + + describe('When clicking 2 times on decrement button', async () => { + test('Then counterValue is 8', async () => { + await render(CounterComponent); + }); + describe('When clicking on Send ', async () => { + test('Then emitted value is 8', async () => { + await render(CounterComponent); + }); + }); + }); }); });