Files
freeCodeCamp/curriculum/challenges/ukrainian/06-quality-assurance/quality-assurance-and-testing-with-chai/test-if-a-value-is-an-array.md

78 lines
2.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: 587d824d367417b2b2512c50
title: Перевірте, чи є значення масивом
challengeType: 2
forumTopicId: 301600
dashedName: test-if-a-value-is-an-array
---
# --description--
Нагадуємо, що цей проєкт створюється на основі наступного початкового проєкту на [ Replit](https://replit.com/github/freeCodeCamp/boilerplate-mochachai) або копіюється з [ GitHub](https://github.com/freeCodeCamp/boilerplate-mochachai/).
# --instructions--
У межах `tests/1_unit-tests.js` під тестом з міткою `#11` в наборі `Arrays` змініть кожний `assert` на `assert.isArray` або `assert.isNotArray` щоб полегшити проходження тесту (варто оцінювати як `true`). Не змінюйте аргументи, передані до тверджень.
# --hints--
Необхідно пройти усі тести.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=10').then(
(data) => {
assert.equal(data.state, 'passed');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
Потрібно обрати правильний метод для першого твердження - `isArray` vs. `isNotArray`.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=10').then(
(data) => {
assert.equal(
data.assertions[0].method,
'isArray',
'String.prototype.split() returns an Array'
);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
```
Потрібно обрати правильний метод для другого твердження - `isArray` vs. `isNotArray`.
```js
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=10').then(
(data) => {
assert.equal(
data.assertions[1].method,
'isNotArray',
'Array.prototype.indexOf() returns a number'
);
},
(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.
*/
```