112 lines
3.3 KiB
Markdown
112 lines
3.3 KiB
Markdown
![]() |
---
|
||
|
id: 587d824b367417b2b2512c4b
|
||
|
title: トリプルイコールを使用して厳密等価をアサートする
|
||
|
challengeType: 2
|
||
|
forumTopicId: 301610
|
||
|
dashedName: use-the-triple-equals-to-assert-strict-equality
|
||
|
---
|
||
|
|
||
|
# --description--
|
||
|
|
||
|
注意点として、このプロジェクトは [Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) の始動プロジェクト、または [GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/) からクローンされたプロジェクトに基づいて構築されています。
|
||
|
|
||
|
`strictEqual()` は、`===` を使用してオブジェクトを比較します。
|
||
|
|
||
|
# --instructions--
|
||
|
|
||
|
`tests/1_unit-tests.js` 内で、`Equality` スイートの `#6` に分類されるテストにおいて、(`true` と評価する必要がある) テストに合格にするために、各 `assert` を `assert.strictEqual` または `assert.notStrictEqual` のいずれかに変更してください。 アサートに渡された引数を変更しないでください。
|
||
|
|
||
|
# --hints--
|
||
|
|
||
|
すべてのテストに合格する必要があります。
|
||
|
|
||
|
```js
|
||
|
(getUserInput) =>
|
||
|
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=5').then(
|
||
|
(data) => {
|
||
|
assert.equal(data.state, 'passed');
|
||
|
},
|
||
|
(xhr) => {
|
||
|
throw new Error(xhr.responseText);
|
||
|
}
|
||
|
);
|
||
|
```
|
||
|
|
||
|
最初のアサーションに対して、正しいメソッドを選ぶ必要があります - `strictEqual` もしくは `notStrictEqual` です。
|
||
|
|
||
|
```js
|
||
|
(getUserInput) =>
|
||
|
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=5').then(
|
||
|
(data) => {
|
||
|
assert.equal(
|
||
|
data.assertions[0].method,
|
||
|
'notStrictEqual',
|
||
|
'with strictEqual the type must match'
|
||
|
);
|
||
|
},
|
||
|
(xhr) => {
|
||
|
throw new Error(xhr.responseText);
|
||
|
}
|
||
|
);
|
||
|
```
|
||
|
|
||
|
2 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `strictEqual` もしくは `notStrictEqual` です。
|
||
|
|
||
|
```js
|
||
|
(getUserInput) =>
|
||
|
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=5').then(
|
||
|
(data) => {
|
||
|
assert.equal(data.assertions[1].method, 'strictEqual', '3*2 = 6...');
|
||
|
},
|
||
|
(xhr) => {
|
||
|
throw new Error(xhr.responseText);
|
||
|
}
|
||
|
);
|
||
|
```
|
||
|
|
||
|
3 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `strictEqual` もしくは `notStrictEqual` です。
|
||
|
|
||
|
```js
|
||
|
(getUserInput) =>
|
||
|
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=5').then(
|
||
|
(data) => {
|
||
|
assert.equal(
|
||
|
data.assertions[2].method,
|
||
|
'strictEqual',
|
||
|
"6 * '2' is 12. Types match !"
|
||
|
);
|
||
|
},
|
||
|
(xhr) => {
|
||
|
throw new Error(xhr.responseText);
|
||
|
}
|
||
|
);
|
||
|
```
|
||
|
|
||
|
4 番目のアサーションに対して、正しいメソッドを選ぶ必要があります - `strictEqual` もしくは `notStrictEqual` です。
|
||
|
|
||
|
```js
|
||
|
(getUserInput) =>
|
||
|
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=5').then(
|
||
|
(data) => {
|
||
|
assert.equal(
|
||
|
data.assertions[3].method,
|
||
|
'notStrictEqual',
|
||
|
'Even if they have the same elements, the Arrays are notStrictEqual'
|
||
|
);
|
||
|
},
|
||
|
(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.
|
||
|
*/
|
||
|
```
|