freeCodeCamp/curriculum/challenges/portuguese/06-quality-assurance/quality-assurance-and-testi.../use-assert.isok-and-assert....

88 lines
2.7 KiB
Markdown
Raw Normal View History

---
id: 587d824b367417b2b2512c48
title: Usar Assert.isOK e Assert.isNotOK
challengeType: 2
forumTopicId: 301607
dashedName: use-assert-isok-and-assert-isnotok
---
# --description--
Lembrando que este projeto está sendo construído a partir do <a href="https://replit.com/github/freeCodeCamp/boilerplate-mochachai" target="_blank" rel="noopener noreferrer nofollow">Replit</a>, ou pode ser clonado no <a href="https://github.com/freeCodeCamp/boilerplate-mochachai/" target="_blank" rel="noopener noreferrer nofollow">GitHub</a>.
`isOk()` testará se um valor é verdadeiro e `isNotOk()` testará se um valor é falso.
Para saber mais sobre valores verdadeiros e falsos, experimente nosso <a href="https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/falsy-bouncer" target="_blank" rel="noopener noreferrer nofollow">desafio</a> Remover falsos.
# --instructions--
Em `tests/1_unit-tests.js`, no teste classificado como `#3` e na suíte `Basic Assertions`, modifique cada `assert` para `assert.isOk()` ou para `assert.isNotOk()`, de maneira que cada teste passe (seja avaliado como `true`). Não altere os argumentos passados às afirmações.
# --hints--
Todos os testes devem passar.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=2').then(
(data) => {
assert.equal(data.state, 'passed');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
Você deve escolher o método correto para a primeira afirmação - `isOk` ou `isNotOk`.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=2').then(
(data) => {
assert.equal(data.assertions[0].method, 'isNotOk', 'Null is falsy');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
Você deve escolher o método correto para a segunda afirmação - `isOk` ou `isNotOk`.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=2').then(
(data) => {
assert.equal(data.assertions[1].method, 'isOk', 'A string is truthy');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
Você deve escolher o método correto para a terceira afirmação - `isOk` ou `isNotOk`.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=2').then(
(data) => {
assert.equal(data.assertions[2].method, 'isOk', 'true is truthy');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
# --solutions--
```js
/**
Backend challenges don't need solutions,
because they would need to be tested against a full working project.
Please check our contributing guidelines to learn more.
*/
```