diff --git a/1-js/03-code-quality/05-testing-mocha/3-pow-test-wrong/solution.md b/1-js/03-code-quality/05-testing-mocha/3-pow-test-wrong/solution.md index 4d0571b9d..fc2fe8146 100644 --- a/1-js/03-code-quality/05-testing-mocha/3-pow-test-wrong/solution.md +++ b/1-js/03-code-quality/05-testing-mocha/3-pow-test-wrong/solution.md @@ -1,50 +1,50 @@ -The test demonstrates one of the temptations a developer meets when writing tests. +Tento test ukazuje jedno z pokušení, kterým vývojář při psaní testů čelí. -What we have here is actually 3 tests, but layed out as a single function with 3 asserts. +To, co zde máme, jsou ve skutečnosti 3 testy, ale jsou vytvořeny jako jediná funkce se 3 kontrolami. -Sometimes it's easier to write this way, but if an error occurs, it's much less obvious what went wrong. +Někdy je jednodušší psát takto, ale když nastane chyba, je mnohem méně zřejmé, co bylo špatně. -If an error happens in the middle of a complex execution flow, then we'll have to figure out the data at that point. We'll actually have to *debug the test*. +Nastane-li chyba uprostřed složitého provádění, musíme v té chvíli zjišťovat, jaká byla data. Vlastně musíme *ladit test*. -It would be much better to break the test into multiple `it` blocks with clearly written inputs and outputs. +Bylo by mnohem lepší rozdělit test do několika `it` bloků s jasně uvedenými vstupy a výstupy. -Like this: +Například takto: ```js -describe("Raises x to power n", function() { - it("5 in the power of 1 equals 5", function() { - assert.equal(pow(5, 1), 5); +describe("Umocní x na n-tou", function() { + it("5 na 1 se rovná 5", function() { + assert.equal(mocnina(5, 1), 5); }); - it("5 in the power of 2 equals 25", function() { - assert.equal(pow(5, 2), 25); + it("5 na 2 se rovná 25", function() { + assert.equal(mocnina(5, 2), 25); }); - it("5 in the power of 3 equals 125", function() { - assert.equal(pow(5, 3), 125); + it("5 na 3 se rovná 125", function() { + assert.equal(mocnina(5, 3), 125); }); }); ``` -We replaced the single `it` with `describe` and a group of `it` blocks. Now if something fails we would see clearly what the data was. +Nahradili jsme jediné `it` za `describe` a skupinu `it` bloků. Když nyní něco selže, jasně uvidíme, jaká byla data. -Also we can isolate a single test and run it in standalone mode by writing `it.only` instead of `it`: +Nyní můžeme také izolovat jediný test a spustit jej samostatně. To uděláme tak, že napíšeme `it.only` místo `it`: ```js -describe("Raises x to power n", function() { - it("5 in the power of 1 equals 5", function() { - assert.equal(pow(5, 1), 5); +describe("Umocní x na n-tou", function() { + it("5 na 1 se rovná 5", function() { + assert.equal(mocnina(5, 1), 5); }); *!* - // Mocha will run only this block - it.only("5 in the power of 2 equals 25", function() { - assert.equal(pow(5, 2), 25); + // Mocha spustí pouze tento blok + it.only("5 na 2 se rovná 25", function() { + assert.equal(mocnina(5, 2), 25); }); */!* - it("5 in the power of 3 equals 125", function() { - assert.equal(pow(5, 3), 125); + it("5 na 3 se rovná 125", function() { + assert.equal(mocnina(5, 3), 125); }); }); ``` diff --git a/1-js/03-code-quality/05-testing-mocha/3-pow-test-wrong/task.md b/1-js/03-code-quality/05-testing-mocha/3-pow-test-wrong/task.md index 66fece09a..41b26df3a 100644 --- a/1-js/03-code-quality/05-testing-mocha/3-pow-test-wrong/task.md +++ b/1-js/03-code-quality/05-testing-mocha/3-pow-test-wrong/task.md @@ -2,23 +2,23 @@ importance: 5 --- -# What's wrong in the test? +# Co je na tomto testu špatně? -What's wrong in the test of `pow` below? +Co je špatně na níže uvedeném testu funkce `mocnina`? ```js -it("Raises x to the power n", function() { +it("Umocní x na n-tou", function() { let x = 5; - let result = x; - assert.equal(pow(x, 1), result); + let výsledek = x; + assert.equal(mocnina(x, 1), výsledek); - result *= x; - assert.equal(pow(x, 2), result); + výsledek *= x; + assert.equal(mocnina(x, 2), výsledek); - result *= x; - assert.equal(pow(x, 3), result); + výsledek *= x; + assert.equal(mocnina(x, 3), výsledek); }); ``` -P.S. Syntactically the test is correct and passes. +P.S. Syntakticky je tento test korektní a projde. diff --git a/1-js/03-code-quality/05-testing-mocha/article.md b/1-js/03-code-quality/05-testing-mocha/article.md index 79f190370..d35aafd1c 100644 --- a/1-js/03-code-quality/05-testing-mocha/article.md +++ b/1-js/03-code-quality/05-testing-mocha/article.md @@ -1,279 +1,279 @@ -# Automated testing with Mocha +# Automatické testování pomocí Mochy -Automated testing will be used in further tasks, and it's also widely used in real projects. +Automatické testování bude používáno v dalších úlohách a široce se používá i ve skutečných projektech. -## Why do we need tests? +## K čemu potřebujeme testy? -When we write a function, we can usually imagine what it should do: which parameters give which results. +Když píšeme funkci, můžeme si obvykle představit, co by měla dělat: jaké parametry by měly dávat jaké výsledky. -During development, we can check the function by running it and comparing the outcome with the expected one. For instance, we can do it in the console. +Během vývoje můžeme tuto funkci zkontrolovat tak, že ji spustíme a porovnáme její výsledek s očekávaným. Můžeme to udělat například na konzoli. -If something is wrong -- then we fix the code, run again, check the result -- and so on till it works. +Jestliže je něco špatně -- pak opravíme kód, znovu spustíme funkci, zkontrolujeme výsledek -- a tak dále, dokud to nebude fungovat. -But such manual "re-runs" are imperfect. +Avšak takové ruční „znovuspouštění“ není dokonalé. -**When testing a code by manual re-runs, it's easy to miss something.** +**Když testujeme kód tím, že ho znovu ručně spouštíme, můžeme snadno něco přehlédnout.** -For instance, we're creating a function `f`. Wrote some code, testing: `f(1)` works, but `f(2)` doesn't work. We fix the code and now `f(2)` works. Looks complete? But we forgot to re-test `f(1)`. That may lead to an error. +Například vytváříme funkci `f`. Napíšeme kód a testujeme: `f(1)` funguje, ale `f(2)` ne. Opravíme kód a nyní `f(2)` funguje. Vypadá to kompletně? Ale zapomněli jsme znovu otestovat `f(1)`. To může vést k chybě. -That's very typical. When we develop something, we keep a lot of possible use cases in mind. But it's hard to expect a programmer to check all of them manually after every change. So it becomes easy to fix one thing and break another one. +To je velmi typické. Když něco vyvíjíme, máme na paměti mnoho možných případů použití. Těžko však očekávat od programátora, že je po každé změně všechny znovu ručně prověří. Lehce se tedy stává, že opravíme jednu věc a rozbijeme jinou. -**Automated testing means that tests are written separately, in addition to the code. They run our functions in various ways and compare results with the expected.** +**Automatické testování znamená, že testy jsou psány odděleně navíc ke kódu. Různými způsoby spouštějí naše funkce a porovnávají jejich výsledky s očekávanými.** -## Behavior Driven Development (BDD) +## Vývoj řízený chováním (BDD) -Let's start with a technique named [Behavior Driven Development](http://en.wikipedia.org/wiki/Behavior-driven_development) or, in short, BDD. +Začněme technikou nazývanou *Vývoj řízený chováním*, anglicky [Behavior Driven Development](http://en.wikipedia.org/wiki/Behavior-driven_development), zkráceně BDD. -**BDD is three things in one: tests AND documentation AND examples.** +**BDD jsou tři věci v jedné: testy A dokumentace A příklady.** -To understand BDD, we'll examine a practical case of development. +Abychom BDD pochopili, prozkoumáme praktický příklad vývoje. -## Development of "pow": the spec +## Vývoj funkce „mocnina“: specifikace -Let's say we want to make a function `pow(x, n)` that raises `x` to an integer power `n`. We assume that `n≥0`. +Řekněme, že chceme vytvořit funkci `mocnina(x, n)`, která umocní `x` na celočíselný exponent `n`. Předpokládáme, že `n≥0`. -That task is just an example: there's the `**` operator in JavaScript that can do that, but here we concentrate on the development flow that can be applied to more complex tasks as well. +Tato úloha je jenom příklad: v JavaScriptu je operátor `**`, který to umí, ale zde se soustředíme na proces vývoje, který může být aplikován i na složitější úlohy. -Before creating the code of `pow`, we can imagine what the function should do and describe it. +Před vytvořením kódu funkce `mocnina` si představíme, co by tato funkce měla dělat, a popíšeme to. -Such description is called a *specification* or, in short, a spec, and contains descriptions of use cases together with tests for them, like this: +Takový popis se nazývá *specifikace* a obsahuje popisy případů použití společně s jejich testy, například takto: ```js -describe("pow", function() { +describe("mocnina", function() { - it("raises to n-th power", function() { - assert.equal(pow(2, 3), 8); + it("umocní na n-tou", function() { + assert.equal(mocnina(2, 3), 8); }); }); ``` -A spec has three main building blocks that you can see above: +Specifikace má tři hlavní stavební bloky, které vidíte výše: -`describe("title", function() { ... })` -: What functionality we're describing? In our case we're describing the function `pow`. Used to group "workers" -- the `it` blocks. +`describe("název", function() { ... })` +: Jakou funkcionalitu popisujeme? V našem případě popisujeme funkci `mocnina`. Používá se k seskupení „pracovníků“ -- bloků `it`. -`it("use case description", function() { ... })` -: In the title of `it` we *in a human-readable way* describe the particular use case, and the second argument is a function that tests it. +`it("popis případu použití", function() { ... })` +: V titulku `it` popíšeme *lidsky čitelným způsobem* konkrétní případ použití. Druhým argumentem je funkce, která jej otestuje. -`assert.equal(value1, value2)` -: The code inside `it` block, if the implementation is correct, should execute without errors. +`assert.equal(hodnota1, hodnota2)` +: Je-li implementace korektní, kód uvnitř bloku `it` by se měl spustit bez chyb. - Functions `assert.*` are used to check whether `pow` works as expected. Right here we're using one of them -- `assert.equal`, it compares arguments and yields an error if they are not equal. Here it checks that the result of `pow(2, 3)` equals `8`. There are other types of comparisons and checks, that we'll add later. +Funkce `assert.*` se používají k ověření, zda `mocnina` funguje tak, jak očekáváme. Právě zde používáme jednu z nich -- `assert.equal`, která porovná argumenty a vyvolá chybu, pokud si nejsou rovny. Zde zkontroluje, zda výsledek `mocnina(2, 3)` se rovná `8`. Existují i jiné druhy porovnání a kontrol, které přidáme později. -The specification can be executed, and it will run the test specified in `it` block. We'll see that later. +Specifikaci můžeme spustit a ta pak spustí test specifikovaný v bloku `it`. To uvidíme později. -## The development flow +## Proces vývoje -The flow of development usually looks like this: +Proces vývoje obvykle vypadá takto: -1. An initial spec is written, with tests for the most basic functionality. -2. An initial implementation is created. -3. To check whether it works, we run the testing framework [Mocha](http://mochajs.org/) (more details soon) that runs the spec. While the functionality is not complete, errors are displayed. We make corrections until everything works. -4. Now we have a working initial implementation with tests. -5. We add more use cases to the spec, probably not yet supported by the implementations. Tests start to fail. -6. Go to 3, update the implementation till tests give no errors. -7. Repeat steps 3-6 till the functionality is ready. +1. Napíše se úvodní specifikace s testy pro většinu základní funkcionality. +2. Vytvoří se úvodní implementace. +3. Abychom prověřili, zda funguje, spustíme testovací rámec [Mocha](https://mochajs.org/) (více později), který spustí specifikaci. Dokud funkcionalita není úplná, budou se zobrazovat chyby. Provádíme opravy, dokud nebude vše fungovat. +4. Nyní máme funkční úvodní implementaci s testy. +5. Do specifikace přidáváme další případy použití, které implementace pravděpodobně ještě nepodporuje. Testy začnou selhávat. +6. Vrátíme se ke kroku 3 a vylepšujeme implementaci, dokud testy nepřestanou vydávat chyby. +7. Opakujeme kroky 3-6, dokud nebude funkcionalita připravena. -So, the development is *iterative*. We write the spec, implement it, make sure tests pass, then write more tests, make sure they work etc. At the end we have both a working implementation and tests for it. +Vývoj je tedy *iterativní*. Napíšeme specifikaci, implementujeme ji, ujistíme se, že testy projdou, napíšeme další testy, ujistíme se, že projdou, atd. Nakonec máme funkční implementaci i její testy. -Let's see this development flow in our practical case. +Podívejme se na tento proces vývoje v praxi. -The first step is already complete: we have an initial spec for `pow`. Now, before making the implementation, let's use few JavaScript libraries to run the tests, just to see that they are working (they will all fail). +První krok je již téměř hotov: máme úvodní specifikaci funkce `mocnina`. Nyní před vytvořením implementace použijeme několik JavaScriptových knihoven ke spuštění testů, abychom viděli, zda fungují (všechny testy selžou). -## The spec in action +## Specifikace v akci -Here in the tutorial we'll be using the following JavaScript libraries for tests: +V tomto tutoriálu budeme pro testy používat následující JavaScriptové knihovny: -- [Mocha](http://mochajs.org/) -- the core framework: it provides common testing functions including `describe` and `it` and the main function that runs tests. -- [Chai](http://chaijs.com) -- the library with many assertions. It allows to use a lot of different assertions, for now we need only `assert.equal`. -- [Sinon](http://sinonjs.org/) -- a library to spy over functions, emulate built-in functions and more, we'll need it much later. +- [Mocha](https://mochajs.org/) -- jádro rámce: poskytuje běžné testovací funkce včetně `describe` a `it` a hlavní funkci, která spouští testy. +- [Chai](https://www.chaijs.com/) -- knihovna s mnoha kontrolami. Umožňuje nám použít spoustu různých kontrol, ale nyní budeme potřebovat jen `assert.equal`. +- [Sinon](https://sinonjs.org/) -- knihovna k prozkoumávání funkcí, emulování vestavěných funkcí a podobně. Budeme ji potřebovat až mnohem později. -These libraries are suitable for both in-browser and server-side testing. Here we'll consider the browser variant. +Tyto knihovny jsou vhodné pro testování v prohlížeči i na straně serveru. Zde budeme uvažovat prohlížečovou variantu. -The full HTML page with these frameworks and `pow` spec: +Celá HTML stránka s těmito rámci a specifikací funkce `mocnina`: ```html src="index.html" ``` -The page can be divided into five parts: +Tuto stránku lze rozdělit do pěti částí: -1. The `` -- add third-party libraries and styles for tests. -2. The ` - + - + - +
- + diff --git a/1-js/03-code-quality/05-testing-mocha/beforeafter.view/test.js b/1-js/03-code-quality/05-testing-mocha/beforeafter.view/test.js index d3de82546..a1dcd5bcc 100644 --- a/1-js/03-code-quality/05-testing-mocha/beforeafter.view/test.js +++ b/1-js/03-code-quality/05-testing-mocha/beforeafter.view/test.js @@ -1,16 +1,16 @@ describe("test", function() { - // Mocha usually waits for the tests for 2 seconds before considering them wrong + // Mocha obvykle čeká na provedení testu 2 sekundy a pak jej považuje za špatný - this.timeout(200000); // With this code we increase this - in this case to 200,000 milliseconds + this.timeout(200000); // S tímto kódem to můžeme zvýšit - v tomto případě na 200 000 milisekund - // This is because of the "alert" function, because if you delay pressing the "OK" button the tests will not pass! + // To je kvůli funkci "alert", protože jestliže budete zaváhat se stisknutím tlačítka "OK", testy neprojdou! - before(() => alert("Testing started – before all tests")); - after(() => alert("Testing finished – after all tests")); + before(() => alert("Začíná testování - před všemi testy")); + after(() => alert("Končí testování - po všech testech")); - beforeEach(() => alert("Before a test – enter a test")); - afterEach(() => alert("After a test – exit a test")); + beforeEach(() => alert("Před testem - vstup do testu")); + afterEach(() => alert("Po testu - výstup z testu")); it('test 1', () => alert(1)); it('test 2', () => alert(2)); diff --git a/1-js/03-code-quality/05-testing-mocha/index.html b/1-js/03-code-quality/05-testing-mocha/index.html index 28a2ea62b..c78960f52 100644 --- a/1-js/03-code-quality/05-testing-mocha/index.html +++ b/1-js/03-code-quality/05-testing-mocha/index.html @@ -1,17 +1,17 @@ - + - + - + @@ -19,18 +19,18 @@ - + - +
- + diff --git a/1-js/03-code-quality/05-testing-mocha/pow-1.view/index.html b/1-js/03-code-quality/05-testing-mocha/pow-1.view/index.html index e48a8d3a2..7a268de82 100644 --- a/1-js/03-code-quality/05-testing-mocha/pow-1.view/index.html +++ b/1-js/03-code-quality/05-testing-mocha/pow-1.view/index.html @@ -1,18 +1,18 @@ - + - + - + @@ -20,18 +20,18 @@ - + - +
- + diff --git a/1-js/03-code-quality/05-testing-mocha/pow-1.view/test.js b/1-js/03-code-quality/05-testing-mocha/pow-1.view/test.js index 89ba412ed..0b6ad7fbd 100644 --- a/1-js/03-code-quality/05-testing-mocha/pow-1.view/test.js +++ b/1-js/03-code-quality/05-testing-mocha/pow-1.view/test.js @@ -1,7 +1,7 @@ -describe("pow", function() { +describe("mocnina", function() { - it("raises to n-th power", function() { - assert.equal(pow(2, 3), 8); + it("umocňuje na n-tou", function() { + assert.equal(mocnina(2, 3), 8); }); }); diff --git a/1-js/03-code-quality/05-testing-mocha/pow-2.view/index.html b/1-js/03-code-quality/05-testing-mocha/pow-2.view/index.html index e8d6be23d..956b6fbb3 100644 --- a/1-js/03-code-quality/05-testing-mocha/pow-2.view/index.html +++ b/1-js/03-code-quality/05-testing-mocha/pow-2.view/index.html @@ -1,18 +1,18 @@ - + - + - + @@ -20,18 +20,18 @@ - + - +
- + diff --git a/1-js/03-code-quality/05-testing-mocha/pow-2.view/test.js b/1-js/03-code-quality/05-testing-mocha/pow-2.view/test.js index c803f0e61..dfda8a632 100644 --- a/1-js/03-code-quality/05-testing-mocha/pow-2.view/test.js +++ b/1-js/03-code-quality/05-testing-mocha/pow-2.view/test.js @@ -1,11 +1,11 @@ -describe("pow", function() { +describe("mocnina", function() { - it("2 raised to power 3 is 8", function() { - assert.equal(pow(2, 3), 8); + it("2 na 3 je 8", function() { + assert.equal(mocnina(2, 3), 8); }); - it("3 raised to power 4 is 81", function() { - assert.equal(pow(3, 4), 81); + it("3 na 4 je 81", function() { + assert.equal(mocnina(3, 4), 81); }); }); diff --git a/1-js/03-code-quality/05-testing-mocha/pow-3.view/index.html b/1-js/03-code-quality/05-testing-mocha/pow-3.view/index.html index c71b0d5d5..4773a9ff9 100644 --- a/1-js/03-code-quality/05-testing-mocha/pow-3.view/index.html +++ b/1-js/03-code-quality/05-testing-mocha/pow-3.view/index.html @@ -1,18 +1,18 @@ - + - + - + @@ -20,24 +20,24 @@ - + - +
- + diff --git a/1-js/03-code-quality/05-testing-mocha/pow-3.view/test.js b/1-js/03-code-quality/05-testing-mocha/pow-3.view/test.js index 8663952aa..268daeaf2 100644 --- a/1-js/03-code-quality/05-testing-mocha/pow-3.view/test.js +++ b/1-js/03-code-quality/05-testing-mocha/pow-3.view/test.js @@ -1,14 +1,14 @@ -describe("pow", function() { +describe("mocnina", function() { - function makeTest(x) { - let expected = x * x * x; - it(`${x} in the power 3 is ${expected}`, function() { - assert.equal(pow(x, 3), expected); + function vytvořTest(x) { + let očekáváno = x * x * x; + it(`${x} na 3 je ${očekáváno}`, function() { + assert.equal(mocnina(x, 3), očekáváno); }); } for (let x = 1; x <= 5; x++) { - makeTest(x); + vytvořTest(x); } }); diff --git a/1-js/03-code-quality/05-testing-mocha/pow-4.view/index.html b/1-js/03-code-quality/05-testing-mocha/pow-4.view/index.html index c71b0d5d5..4773a9ff9 100644 --- a/1-js/03-code-quality/05-testing-mocha/pow-4.view/index.html +++ b/1-js/03-code-quality/05-testing-mocha/pow-4.view/index.html @@ -1,18 +1,18 @@ - + - + - + @@ -20,24 +20,24 @@ - + - +
- + diff --git a/1-js/03-code-quality/05-testing-mocha/pow-4.view/test.js b/1-js/03-code-quality/05-testing-mocha/pow-4.view/test.js index e5ce2ce43..99ff33cf8 100644 --- a/1-js/03-code-quality/05-testing-mocha/pow-4.view/test.js +++ b/1-js/03-code-quality/05-testing-mocha/pow-4.view/test.js @@ -1,19 +1,17 @@ -describe("pow", function() { +describe("mocnina", function() { - describe("raises x to power 3", function() { + describe("umocní x na 3", function() { - function makeTest(x) { - let expected = x * x * x; - it(`${x} in the power 3 is ${expected}`, function() { - assert.equal(pow(x, 3), expected); + function vytvořTest(x) { + let očekáváno = x * x * x; + it(`${x} na 3 je ${očekáváno}`, function() { + assert.equal(mocnina(x, 3), očekáváno); }); } for (let x = 1; x <= 5; x++) { - makeTest(x); + vytvořTest(x); } }); - - // ... more tests to follow here, both describe and it can be added }); diff --git a/1-js/03-code-quality/05-testing-mocha/pow-full.view/index.html b/1-js/03-code-quality/05-testing-mocha/pow-full.view/index.html index 076b1e5a9..f41da18fc 100644 --- a/1-js/03-code-quality/05-testing-mocha/pow-full.view/index.html +++ b/1-js/03-code-quality/05-testing-mocha/pow-full.view/index.html @@ -1,18 +1,18 @@ - + - + - + @@ -20,25 +20,25 @@ - + - +
- + diff --git a/1-js/03-code-quality/05-testing-mocha/pow-full.view/test.js b/1-js/03-code-quality/05-testing-mocha/pow-full.view/test.js index 75ff5e99f..881d8bb5b 100644 --- a/1-js/03-code-quality/05-testing-mocha/pow-full.view/test.js +++ b/1-js/03-code-quality/05-testing-mocha/pow-full.view/test.js @@ -1,26 +1,26 @@ -describe("pow", function() { +describe("mocnina", function() { - describe("raises x to power 3", function() { + describe("umocní x na 3", function() { - function makeTest(x) { - let expected = x * x * x; - it(`${x} in the power 3 is ${expected}`, function() { - assert.equal(pow(x, 3), expected); + function vytvořTest(x) { + let očekáváno = x * x * x; + it(`${x} na 3 je ${očekáváno}`, function() { + assert.equal(mocnina(x, 3), očekáváno); }); } for (let x = 1; x <= 5; x++) { - makeTest(x); + vytvořTest(x); } }); - it("if n is negative, the result is NaN", function() { - assert.isNaN(pow(2, -1)); + it("je-li n záporné, výsledek je NaN", function() { + assert.isNaN(mocnina(2, -1)); }); - it("if n is not integer, the result is NaN", function() { - assert.isNaN(pow(2, 1.5)); + it("je-li n necelé, výsledek je NaN", function() { + assert.isNaN(mocnina(2, 1.5)); }); }); diff --git a/1-js/03-code-quality/05-testing-mocha/pow-min.view/index.html b/1-js/03-code-quality/05-testing-mocha/pow-min.view/index.html index d82a79dca..8b88e32d3 100644 --- a/1-js/03-code-quality/05-testing-mocha/pow-min.view/index.html +++ b/1-js/03-code-quality/05-testing-mocha/pow-min.view/index.html @@ -1,18 +1,18 @@ - + - + - + @@ -20,21 +20,21 @@ - + - +
- + - + \ No newline at end of file diff --git a/1-js/03-code-quality/05-testing-mocha/pow-min.view/test.js b/1-js/03-code-quality/05-testing-mocha/pow-min.view/test.js index 89ba412ed..981bbaac2 100644 --- a/1-js/03-code-quality/05-testing-mocha/pow-min.view/test.js +++ b/1-js/03-code-quality/05-testing-mocha/pow-min.view/test.js @@ -1,7 +1,7 @@ -describe("pow", function() { +describe("mocnina", function() { - it("raises to n-th power", function() { - assert.equal(pow(2, 3), 8); + it("umocní na n-tou", function() { + assert.equal(mocnina(2, 3), 8); }); }); diff --git a/1-js/03-code-quality/05-testing-mocha/pow-nan.view/index.html b/1-js/03-code-quality/05-testing-mocha/pow-nan.view/index.html index 523ae25ec..4773a9ff9 100644 --- a/1-js/03-code-quality/05-testing-mocha/pow-nan.view/index.html +++ b/1-js/03-code-quality/05-testing-mocha/pow-nan.view/index.html @@ -1,18 +1,18 @@ - + - + - + @@ -20,22 +20,24 @@ - + - +
- + diff --git a/1-js/03-code-quality/05-testing-mocha/pow-nan.view/test.js b/1-js/03-code-quality/05-testing-mocha/pow-nan.view/test.js index 75ff5e99f..88e218c49 100644 --- a/1-js/03-code-quality/05-testing-mocha/pow-nan.view/test.js +++ b/1-js/03-code-quality/05-testing-mocha/pow-nan.view/test.js @@ -1,26 +1,26 @@ -describe("pow", function() { +describe("mocnina", function() { - describe("raises x to power 3", function() { + describe("umocní x na 3", function() { - function makeTest(x) { - let expected = x * x * x; - it(`${x} in the power 3 is ${expected}`, function() { - assert.equal(pow(x, 3), expected); + function vytvořTest(x) { + let očekáváno = x * x * x; + it(`${x} na 3 je ${očekáváno}`, function() { + assert.equal(mocnina(x, 3), očekáváno); }); } for (let x = 1; x <= 5; x++) { - makeTest(x); + vytvořTest(x); } }); - it("if n is negative, the result is NaN", function() { - assert.isNaN(pow(2, -1)); + it("pro záporné n je výsledek NaN", function() { + assert.isNaN(mocnina(2, -1)); }); - it("if n is not integer, the result is NaN", function() { - assert.isNaN(pow(2, 1.5)); + it("pro necelé n je výsledek NaN", function() { + assert.isNaN(mocnina(2, 1.5)); }); });