> [color=#47e8a8] > [name=Lucas] > [time=Tue, Apr 18] > [name=Lukas] > [time=Tue, Apr 18] > https://hackmd.io/@LucLukWissM324/B1Rnc2oGh # SQ09A ## Test 01 ```javascript /** * Testet das Rendern der Überschrift. */ test('renders heading', () => { render(<App />); const headingElement = screen.getByRole('heading', { name: /ToDo Liste/i }); expect(headingElement).toBeInTheDocument(); }); ``` <img src="https://i.imgur.com/EDiczV1.png" style="margin:2vh; filter:drop-shadow(0px 0px 5px black);"> --- ## Test 02 ```javascript /** * Testet das Hinzufügen einer Aufgabe. */ test('allows user to add a new task', async () => { render(<App/>); const inputElement = screen.getByLabelText(/Enter new Task/i); const addButtonElement = screen.getByRole('button', {name: /Save/i}); const taskName = 'Buy_groceries'; fireEvent.change(inputElement, {target: {value: taskName}}); fireEvent.click(addButtonElement); await waitFor(() => { const newTaskElement = screen.getByText(/Buy_groceries/); expect(newTaskElement).toBeInTheDocument(); }); }); ``` <img src="https://i.imgur.com/COmOJCT.png" style="margin:2vh; filter:drop-shadow(0px 0px 5px black);"> --- ## Test 03 ```javascript= /** * Testet ob der Done Button funktioniert. * Buy_groceries wird nicht mehr angezeigt. */ test('done button removes Todo', async () => { render(<App todos={[{ taskdescription: 'Buy_groceries' }]} />); const doneButton = screen.getByRole('button', { name: /Done/i }); fireEvent.click(doneButton); await waitFor(() => { expect(screen.queryByText('Task 1: Buy_groceries')).toBeNull(); }); }); ``` <img src="https://i.imgur.com/IGD3Ekj.png" style="margin:2vh; filter:drop-shadow(0px 0px 5px black);"> --- ## `npm test` <img src="https://i.imgur.com/cyYKUVQ.png" style="margin:2vh; filter:drop-shadow(0px 0px 5px black);"> <img src="https://i.imgur.com/8ij40yi.png" style="margin:2vh; filter:drop-shadow(0px 0px 5px black);"> --- ## Commit auf Gitlab <img src="https://i.imgur.com/PYUA1Vi.png" style="margin:2vh; filter:drop-shadow(0px 0px 5px black);"> Commit auf Gitlab: <img src="https://i.imgur.com/0w16zlH.png" style="margin:2vh; filter:drop-shadow(0px 0px 5px black);">
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up