|
1 |
| -The test demonstrates one of the temptations a developer meets when writing tests. |
| 1 | +Тестът показва едно от изкушенията, с които се сблъскват програмистите, когато пишат тестове. |
2 | 2 |
|
3 |
| -What we have here is actually 3 tests, but layed out as a single function with 3 asserts. |
| 3 | +В действителност тук имаме 3 теста, но разписани като една функция с 3 asserts (допускания). |
4 | 4 |
|
5 |
| -Sometimes it's easier to write this way, but if an error occurs, it's much less obvious what went wrong. |
| 5 | +Понякога е по-лесно да се пише по този начин, но ако има грешка в кода, е по-трудно да се проследи къде е тя. |
6 | 6 |
|
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 | +Ако има грешка по време на изпълнението на сложен код, трябва да се опитаме да разберем какви са данните в този момент. Ц други думи, трябва да *дебъгнем теста*. |
8 | 8 |
|
9 |
| -It would be much better to break the test into multiple `it` blocks with clearly written inputs and outputs. |
| 9 | +Ще бъде много по-лесно ако разделим теста на множество `it` блокове с ясно рязписани входни и изходни данни. |
10 | 10 |
|
11 |
| -Like this: |
| 11 | +Например ето така: |
12 | 12 | ```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() { |
15 | 15 | assert.equal(pow(5, 1), 5);
|
16 | 16 | });
|
17 | 17 |
|
18 |
| - it("5 in the power of 2 equals 25", function() { |
| 18 | + it("5 на степен 2 е равно на 25", function() { |
19 | 19 | assert.equal(pow(5, 2), 25);
|
20 | 20 | });
|
21 | 21 |
|
22 |
| - it("5 in the power of 3 equals 125", function() { |
| 22 | + it("5 на степен 3 е равно на 125", function() { |
23 | 23 | assert.equal(pow(5, 3), 125);
|
24 | 24 | });
|
25 | 25 | });
|
26 | 26 | ```
|
27 | 27 |
|
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` блокове. Сега ако нещо не работи, ще можем лесно да видим какви са били данните. |
29 | 29 |
|
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`: |
31 | 31 |
|
32 | 32 |
|
33 | 33 | ```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() { |
36 | 36 | assert.equal(pow(5, 1), 5);
|
37 | 37 | });
|
38 | 38 |
|
39 | 39 | *!*
|
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() { |
42 | 42 | assert.equal(pow(5, 2), 25);
|
43 | 43 | });
|
44 | 44 | */!*
|
45 | 45 |
|
46 |
| - it("5 in the power of 3 equals 125", function() { |
| 46 | + it("5 на степен 3 е равно на 125", function() { |
47 | 47 | assert.equal(pow(5, 3), 125);
|
48 | 48 | });
|
49 | 49 | });
|
|
0 commit comments