Skip to content

Commit 0280418

Browse files
authored
393
1 parent d0c6db4 commit 0280418

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

1-js/03-code-quality/05-testing-mocha/article.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -333,22 +333,22 @@ describe("pow", function() {
333333

334334
[iframe height=530 src="pow-nan" edit border="1"]
335335

336-
The newly added tests fail, because our implementation does not support them. That's how BDD is done: first we write failing tests, and then make an implementation for them.
336+
Новодобавените тестове ще са неуспешним защото нашата имплементация не ги поддържа. Така се прави BDD: първо пишем тестове, които не минават и после правим тяхната имплементация.
337337

338-
```smart header="Other assertions"
339-
Please note the assertion `assert.isNaN`: it checks for `NaN`.
338+
```smart header="Други допускания"
339+
Обърнете внимание на допускането `assert.isNaN`: то проверява за `NaN`.
340340
341-
There are other assertions in [Chai](http://chaijs.com) as well, for instance:
341+
Има и други допускания в [Chai](http://chaijs.com) например:
342342
343-
- `assert.equal(value1, value2)` -- checks the equality `value1 == value2`.
344-
- `assert.strictEqual(value1, value2)` -- checks the strict equality `value1 === value2`.
345-
- `assert.notEqual`, `assert.notStrictEqual` -- inverse checks to the ones above.
346-
- `assert.isTrue(value)` -- checks that `value === true`
347-
- `assert.isFalse(value)` -- checks that `value === false`
348-
- ...the full list is in the [docs](http://chaijs.com/api/assert/)
343+
- `assert.equal(value1, value2)` -- проверява за равенство `value1 == value2`.
344+
- `assert.strictEqual(value1, value2)` -- проверява за абсолютно равенство `value1 === value2`.
345+
- `assert.notEqual`, `assert.notStrictEqual` -- проверява за неравенство.
346+
- `assert.isTrue(value)` -- проверява дали стойността е истина `value === true`
347+
- `assert.isFalse(value)` -- проверява дали стойността е неистина `value === false`
348+
- ...пълният списък е на [docs](http://chaijs.com/api/assert/)
349349
```
350350

351-
So we should add a couple of lines to `pow`:
351+
Така че трябва да добавим няколко реда към `pow`:
352352

353353
```js
354354
function pow(x, n) {
@@ -367,29 +367,29 @@ function pow(x, n) {
367367
}
368368
```
369369

370-
Now it works, all tests pass:
370+
Сега работи и всички тестове са успешни:
371371

372372
[iframe height=300 src="pow-full" edit border="1"]
373373

374-
[edit src="pow-full" title="Open the full final example in the sandbox."]
374+
[edit src="pow-full" title="Oтвори финалният пример в тестовата среда."]
375375

376-
## Summary
376+
## Обобщение
377377

378-
In BDD, the spec goes first, followed by implementation. At the end we have both the spec and the code.
378+
В BDD, спецификацията винаги е пръва, следвана от импелментацията. Накрая имаме спецификация и код към нея.
379379

380-
The spec can be used in three ways:
380+
Спецификацията може да се използва по три начина:
381381

382-
1. As **Tests** - they guarantee that the code works correctly.
383-
2. As **Docs** -- the titles of `describe` and `it` tell what the function does.
384-
3. As **Examples** -- the tests are actually working examples showing how a function can be used.
382+
1. Като **Тестове** - те гарантират, че кода работи правилно.
383+
2. Като **Документация** -- заглавията на `describe` и `it` казват какво прави функцията.
384+
3. Като **Примери** -- тестовете всъщност са работещи примери, които показват как да се използа функцията.
385385

386-
With the spec, we can safely improve, change, even rewrite the function from scratch and make sure it still works right.
386+
Със спека ние безопасно можем да подобрим, променим или дори пренапишем функцията и тя пак да работи правилно.
387387

388-
That's especially important in large projects when a function is used in many places. When we change such a function, there's just no way to manually check if every place that uses it still works right.
388+
Това е особено важно за големи проекти, където функцията се използва на много места. Когато променим такава функция, просто няма начин да проверим ръчно всички места където се използва, за да сме сигурни, че още работи правилно.
389389

390-
Without tests, people have two ways:
390+
Без тестове хората имат два начина:
391391

392-
1. To perform the change, no matter what. And then our users meet bugs, as we probably fail to check something manually.
392+
1. Да направят промяната въпреки всичко. И тогава нашите потребители се натъкват на бъгове, тъй като ние най-вероятно не сме успели да а проверим всичко на ръка.
393393
2. Or, if the punishment for errors is harsh, as there are no tests, people become afraid to modify such functions, and then the code becomes outdated, no one wants to get into it. Not good for development.
394394

395395
**Automatic testing helps to avoid these problems!**

0 commit comments

Comments
 (0)