2.8 KiB
2.8 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d824b367417b2b2512c4a | Usar o sinal duplo de igual para avaliar igualdade | 2 | 301609 | use-the-double-equals-to-assert-equality |
--description--
Lembrando que este projeto está sendo construído a partir do Replit, ou pose ser clonado no GitHub.
equal()
compara objetos usando ==
.
--instructions--
Em tests/1_unit-tests.js
, no teste classificado como #5
e na suíte Equality
, modifique cada assert
para assert.equal
ou para assert.notEqual
, 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.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=4').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 - equal
ou notEqual
.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=4').then(
(data) => {
assert.equal(
data.assertions[0].method,
'equal',
'Numbers are coerced into strings with == '
);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
Você deve escolher o método correto para a segunda afirmação - equal
ou notEqual
.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=4').then(
(data) => {
assert.equal(
data.assertions[1].method,
'notEqual',
' == compares object references'
);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
Você deve escolher o método correto para a terceira afirmação - equal
ou notEqual
.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=4').then(
(data) => {
assert.equal(
data.assertions[2].method,
'equal',
"6 * '2' is 12 ! It should be equal to '12'"
);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
Você deve escolher o método correto para a quarta afirmação - equal
ou notEqual
.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=4').then(
(data) => {
assert.equal(data.assertions[3].method, 'notEqual', "6 + '2' is '62'...");
},
(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.
*/