80 lines
2.3 KiB
Markdown
80 lines
2.3 KiB
Markdown
---
|
|
id: 587d824c367417b2b2512c4c
|
|
title: Assegurar a igualdade profunda com .deepEqual e .notDeepEqual
|
|
challengeType: 2
|
|
forumTopicId: 301587
|
|
dashedName: assert-deep-equality-with--deepequal-and--notdeepequal
|
|
---
|
|
|
|
# --description--
|
|
|
|
Lembrando que este projeto está sendo construído a partir do projeto inicial no <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>.
|
|
|
|
`deepEqual()` assegura que dois objetos são profundamente iguais.
|
|
|
|
# --instructions--
|
|
|
|
Em `tests/1_unit-tests.js`, no teste classificado como `#7` e na suíte `Equality`, modifique cada `assert` para `assert.deepEqual` ou para `assert.notDeepEqual`, 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=6').then(
|
|
(data) => {
|
|
assert.equal(data.state, 'passed');
|
|
},
|
|
(xhr) => {
|
|
throw new Error(xhr.responseText);
|
|
}
|
|
);
|
|
```
|
|
|
|
Você deve escolher o método correto para a primeira declaração - `deepEqual` ou `notDeepEqual`.
|
|
|
|
```js
|
|
(getUserInput) =>
|
|
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=6').then(
|
|
(data) => {
|
|
assert.equal(
|
|
data.assertions[0].method,
|
|
'deepEqual',
|
|
'The order of the keys does not matter'
|
|
);
|
|
},
|
|
(xhr) => {
|
|
throw new Error(xhr.responseText);
|
|
}
|
|
);
|
|
```
|
|
|
|
Você deve escolher o método correto para a segunda declaração - `deepEqual` ou `notDeepEqual`.
|
|
|
|
```js
|
|
(getUserInput) =>
|
|
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=6').then(
|
|
(data) => {
|
|
assert.equal(
|
|
data.assertions[1].method,
|
|
'notDeepEqual',
|
|
'The position of elements within an array does matter'
|
|
);
|
|
},
|
|
(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.
|
|
*/
|
|
```
|