Skip to content

Commit 1f00bfe

Browse files
authored
Merge pull request #24 from mtsonkova/patch-7
Automated testing with Mocha
2 parents 75ce3de + aeeabbb commit 1f00bfe

File tree

1 file changed

+17
-17
lines changed
  • 1-js/03-code-quality/05-testing-mocha/3-pow-test-wrong

1 file changed

+17
-17
lines changed

1-js/03-code-quality/05-testing-mocha/3-pow-test-wrong/solution.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
The test demonstrates one of the temptations a developer meets when writing tests.
1+
Тестът показва едно от изкушенията, с които се сблъскват програмистите, когато пишат тестове.
22

3-
What we have here is actually 3 tests, but layed out as a single function with 3 asserts.
3+
В действителност тук имаме 3 теста, но разписани като една функция с 3 asserts (допускания).
44

5-
Sometimes it's easier to write this way, but if an error occurs, it's much less obvious what went wrong.
5+
Понякога е по-лесно да се пише по този начин, но ако има грешка в кода, е по-трудно да се проследи къде е тя.
66

7-
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*.
7+
Ако има грешка по време на изпълнението на сложен код, трябва да се опитаме да разберем какви са данните в този момент. Ц други думи, трябва да *дебъгнем теста*.
88

9-
It would be much better to break the test into multiple `it` blocks with clearly written inputs and outputs.
9+
Ще бъде много по-лесно ако разделим теста на множество `it` блокове с ясно рязписани входни и изходни данни.
1010

11-
Like this:
11+
Например ето така:
1212
```js
13-
describe("Raises x to power n", function() {
14-
it("5 in the power of 1 equals 5", function() {
13+
describe("Повдига x на степен n", function() {
14+
it("5 на степен 1 е равно на 5", function() {
1515
assert.equal(pow(5, 1), 5);
1616
});
1717

18-
it("5 in the power of 2 equals 25", function() {
18+
it("5 на степен 2 е равно на 25", function() {
1919
assert.equal(pow(5, 2), 25);
2020
});
2121

22-
it("5 in the power of 3 equals 125", function() {
22+
it("5 на степен 3 е равно на 125", function() {
2323
assert.equal(pow(5, 3), 125);
2424
});
2525
});
2626
```
2727

28-
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.
28+
Заместихме единичния `it` с `describe` и група от `it` блокове. Сега ако нещо не работи, ще можем лесно да видим какви са били данните.
2929

30-
Also we can isolate a single test and run it in standalone mode by writing `it.only` instead of `it`:
30+
Също можем да изолираме единичен тест и да го стартираме самостоятелно като напишем `it.only` вместо `it`:
3131

3232

3333
```js
34-
describe("Raises x to power n", function() {
35-
it("5 in the power of 1 equals 5", function() {
34+
describe("Повдига x на степен n", function() {
35+
it("5 на степен 1 е равно на 5", function() {
3636
assert.equal(pow(5, 1), 5);
3737
});
3838

3939
*!*
40-
// Mocha will run only this block
41-
it.only("5 in the power of 2 equals 25", function() {
40+
// Mocha ще стартира само този блок
41+
it.only("5 на степен 2 е равно на 25", function() {
4242
assert.equal(pow(5, 2), 25);
4343
});
4444
*/!*
4545

46-
it("5 in the power of 3 equals 125", function() {
46+
it("5 на степен 3 е равно на 125", function() {
4747
assert.equal(pow(5, 3), 125);
4848
});
4949
});

0 commit comments

Comments
 (0)