2.8 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d824b367417b2b2512c49 | Pruebas de veracidad | 2 | 301596 | test-for-truthiness |
--description--
Como recordatorio, este proyecto está siendo construido con base en el siguiente proyecto inicial Replit, o clonado desde GitHub.
isTrue()
probará el valor booleano true
y isNotTrue()
pasará cuando se le dé cualquier cosa que no sea el valor booleano de true
.
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');
isFalse()
y isNotFalse()
también existen, y se comportan de manera similar a sus contrapartes verdaderas excepto que buscan el valor booleano de false
.
--instructions--
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.
--hints--
Todas las pruebas deben pasar.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=3').then(
(data) => {
assert.equal(data.state, 'passed');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
Debes elegir el método correcto para la primera afirmación - isTrue
vs. isNotTrue
.
(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);
}
);
Debes elegir el método correcto para la segunda afirmación: isTrue
vs. isNotTrue
.
(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);
}
);
Debes elegir el método correcto para la tercera afirmación: isTrue
vs. isNotTrue
.
(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--
/**
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.
*/