2.4 KiB
2.4 KiB
id, title, challengeType, forumTopicId, localeTitle
id | title | challengeType | forumTopicId | localeTitle |
---|---|---|---|---|
587d824b367417b2b2512c48 | Use Assert.isOK and Assert.isNotOK | 2 | 301607 | 使用 Assert.isOk() 和 Assert.isNotOK() |
Description
isOk()
用来测试值是否为 truthy
;isNotOk()
用来测试值是否为 falsy
。
如果你想了解更多关于 truthy 和 falsy 值的内容,请参阅 Falsy Bouncer 这道挑战题目。
Instructions
使用 assert.isOk()
或 assert.isNotOk()
让测试通过。
Tests
tests:
- text: 不应有未通过的测试
testString: getUserInput => $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=2').then(data => {assert.equal(data.state,'passed'); }, xhr => { throw new Error(xhr.responseText); })
- text: 请选择正确的断言—isOk 或 isNotOk
testString: getUserInput => $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=2').then(data => { assert.equal(data.assertions[0].method, 'isNotOk', 'Null is falsy'); }, xhr => { throw new Error(xhr.responseText); })
- text: 请选择正确的断言—isOk 或 isNotOk
testString: getUserInput => $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=2').then(data => { assert.equal(data.assertions[1].method, 'isOk','A string is truthy'); }, xhr => { throw new Error(xhr.responseText); })
- text: 请选择正确的断言—isOk 或 isNotOk
testString: getUserInput => $.get(getUserInput('url') + '/_api/get-tests?type=unit&n=2').then(data => { assert.equal(data.assertions[2].method, 'isOk', 'true is truthy'); }, xhr => { throw new Error(xhr.responseText); })
Challenge Seed
Solution
/**
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.
*/