2021-02-06 04:42:36 +00:00
---
id: 587d824b367417b2b2512c49
2022-01-12 20:10:05 +05:30
title: Pruebas de veracidad
2021-02-06 04:42:36 +00:00
challengeType: 2
forumTopicId: 301596
dashedName: test-for-truthiness
---
# --description--
2022-01-12 20:10:05 +05:30
Como recordatorio, este proyecto está siendo construido con base en el siguiente proyecto inicial [Replit ](https://replit.com/github/freeCodeCamp/boilerplate-mochachai ), o clonado desde [GitHub ](https://github.com/freeCodeCamp/boilerplate-mochachai/ ).
2021-02-06 04:42:36 +00:00
2022-01-12 20:10:05 +05:30
`isTrue()` probará el valor booleano `true` y `isNotTrue()` pasará cuando se le dé cualquier cosa que no sea el valor booleano de `true` .
2021-02-06 04:42:36 +00:00
```js
2022-01-12 20:10:05 +05:30
assert.isTrue(true, 'This will pass with the boolean value true');
assert.isTrue('true', 'This will NOT pass with the string value "true"');
assert.isTrue(1, 'This will NOT pass with the number value 1');
2021-02-06 04:42:36 +00:00
```
2022-01-12 20:10:05 +05:30
`isFalse()` y `isNotFalse()` también existen, y se comportan de manera similar a sus contrapartes verdaderas excepto que buscan el valor booleano de `false` .
2021-02-06 04:42:36 +00:00
# --instructions--
2022-01-12 20:10:05 +05:30
Dentro de `tests/1_unit-tests.js` bajo la prueba etiquetada `#4` en la `Basic Assertions` , cambia cada `assert` a `assert.isTrue` o `assert.isNotTrue` para hacer que la prueba pase (debe evaluarse como `true` ). No modifiques los argumentos pasados a los verificadores.
2021-02-06 04:42:36 +00:00
# --hints--
2022-01-12 20:10:05 +05:30
Todas las pruebas deben pasar.
2021-02-06 04:42:36 +00:00
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit& n=3').then(
(data) => {
assert.equal(data.state, 'passed');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
2022-01-12 20:10:05 +05:30
Debes elegir el método correcto para la primera afirmación - `isTrue` vs. `isNotTrue` .
2021-02-06 04:42:36 +00:00
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit& n=3').then(
(data) => {
assert.equal(data.assertions[0].method, 'isTrue', 'True is true');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
2022-01-12 20:10:05 +05:30
Debes elegir el método correcto para la segunda afirmación: `isTrue` vs. `isNotTrue` .
2021-02-06 04:42:36 +00:00
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit& n=3').then(
(data) => {
assert.equal(
data.assertions[1].method,
'isTrue',
'Double negation of a truthy value is true'
);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
2022-01-12 20:10:05 +05:30
Debes elegir el método correcto para la tercera afirmación: `isTrue` vs. `isNotTrue` .
2021-02-06 04:42:36 +00:00
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit& n=3').then(
(data) => {
assert.equal(
data.assertions[2].method,
'isNotTrue',
'A truthy object is not true - neither is a false one'
);
},
(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.
*/
```