Skip to content
Snippets Groups Projects
Commit c77e725c authored by Toni Salo's avatar Toni Salo
Browse files

setup & teardown lisätty, mutta worker ei silti tajua lopettaa tyylikkäästi

parent abbf9597
No related branches found
No related tags found
No related merge requests found
import { getByText, render, screen } from '@testing-library/react'; import { getByText, render, screen } from '@testing-library/react';
import React from 'react'; import React from 'react';
import { unmountComponentAtNode } from "react-dom"; import { unmountComponentAtNode } from "react-dom";
import { act } from "react-dom/test-utils";
import userEvent from '@testing-library/user-event' import userEvent from '@testing-library/user-event'
import App from './App'; import App from './App';
import {Soitinmenu} from './App'; import {Soitinmenu} from './App';
import {Oktaavinvaihto} from './App';
import AudioContext from "./AudioContext"
import AudioPlayer from './AudioPlayer';
let container = null; let container = null;
beforeEach(() => { beforeEach(() => {
...@@ -22,11 +20,10 @@ afterEach(() => { ...@@ -22,11 +20,10 @@ afterEach(() => {
container = null; container = null;
}); });
// testaa soittimen valitsevaa select-elementtiä // testaa soittimen valitsevaa select-elementtiä
// yhden valitun ja ei valitun soittimen löytyminen todistaa, että menu löytyy // yhden valitun ja ei valitun soittimen löytyminen todistaa, että menu löytyy
test('soittimen valinta', () => { test('soittimen valinta', () => {
render(<Soitinmenu />) act(() => { render(<Soitinmenu />, container); });
const piano = screen.getByText("piano"); const piano = screen.getByText("piano");
const sello = screen.getByText("sello"); const sello = screen.getByText("sello");
const element = document.getElementById('smenu'); const element = document.getElementById('smenu');
...@@ -82,8 +79,8 @@ test('paina kosketinta', () =>{ ...@@ -82,8 +79,8 @@ test('paina kosketinta', () =>{
})*/ })*/
// Näkyvätkö kaikki koskettimet ohjeteksteineen? // Näkyvätkö kaikki koskettimet ohjeteksteineen?
test('kirjainvihjeet matalat nuotit', () => { test('kirjainvihjeet', () => {
render(<App />); act(() => { render(<App />, container); });
const moment = screen.getByText(/§/i); const moment = screen.getByText(/§/i);
const eka = screen.getByText("1"); const eka = screen.getByText("1");
const q = screen.getByText(/q/i); const q = screen.getByText(/q/i);
...@@ -115,11 +112,7 @@ test('kirjainvihjeet matalat nuotit', () => { ...@@ -115,11 +112,7 @@ test('kirjainvihjeet matalat nuotit', () => {
expect(seiska).toBeInTheDocument(); expect(seiska).toBeInTheDocument();
expect(u).toBeInTheDocument(); expect(u).toBeInTheDocument();
expect(i).toBeInTheDocument(); expect(i).toBeInTheDocument();
});
// Näkyvätkö kaikki koskettimet ohjeteksteineen?
test('kirjainvihjeet korkeat nuotit', () => {
render(<App />);
const a = screen.getByText(/a9/i); const a = screen.getByText(/a9/i);
const z = screen.getByText(/zo/i); const z = screen.getByText(/zo/i);
const s = screen.getByText(/s0/i); const s = screen.getByText(/s0/i);
...@@ -163,7 +156,7 @@ test('kirjainvihjeet korkeat nuotit', () => { ...@@ -163,7 +156,7 @@ test('kirjainvihjeet korkeat nuotit', () => {
// oktaavin muutosnapit // oktaavin muutosnapit
test('muut napit', () => { test('muut napit', () => {
render(<App />); act(() => { render(<App />, container); });
const nosto = screen.getByText("Nosta oktaavilla"); const nosto = screen.getByText("Nosta oktaavilla");
const lasku = screen.getByText("Laske oktaavilla"); const lasku = screen.getByText("Laske oktaavilla");
expect(nosto).toBeInTheDocument(); expect(nosto).toBeInTheDocument();
...@@ -173,7 +166,7 @@ test('kirjainvihjeet korkeat nuotit', () => { ...@@ -173,7 +166,7 @@ test('kirjainvihjeet korkeat nuotit', () => {
}); });
//Onko ruudulla juuri oikea näkymä? //Onko ruudulla juuri oikea näkymä?
it('snapshot', () => { test('snapshot', () => {
const { asFragment } = render(<App />) const { asFragment } = render(<App />)
expect(asFragment(<App />)).toMatchSnapshot() expect(asFragment(<App />)).toMatchSnapshot()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment