2.8 KiB
2.8 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d824b367417b2b2512c47 | Перевірте, чи визначено змінну або функцію | 2 | 301602 | test-if-a-variable-or-function-is-defined |
--description--
Нагадуємо, що цей проєкт створюється на основі наступного початкового проєкту на Replit або копіюється з GitHub.
--instructions--
У межах tests/1_unit-tests.js
під тестом з міткою #2
в наборі Basic Assertions
змініть кожний assert
на assert.isDefined()
або assert.isUndefined()
щоб полегшити проходження тесту (варто оцінювати як true
). Не змінюйте аргументи, передані до тверджень.
--hints--
Всі тести повинні бути успішно пройдені.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=1').then(
(data) => {
assert.equal(data.state, 'passed');
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
Потрібно обрати правильний метод для першого твердження isDefined
або isUndefined
.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=1').then(
(data) => {
assert.equal(
data.assertions[0].method,
'isDefined',
'Null is not undefined'
);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
Потрібно обрати правильний метод для другого твердження isDefined
або isUndefined
.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=1').then(
(data) => {
assert.equal(
data.assertions[1].method,
'isUndefined',
'Undefined is undefined'
);
},
(xhr) => {
throw new Error(xhr.responseText);
}
);
Потрібно обрати правильний метод для третього твердження isDefined
або isUndefined
.
(getUserInput) =>
$.get(getUserInput('url') + '/_api/get-tests?type=unit&n=1').then(
(data) => {
assert.equal(
data.assertions[2].method,
'isDefined',
'A string is not undefined'
);
},
(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.
*/