2018-10-12 15:37:13 -04:00
|
|
|
---
|
|
|
|
|
title: Use Assert.isOK and Assert.isNotOK
|
|
|
|
|
---
|
2019-07-24 00:59:27 -07:00
|
|
|
# Use Assert.isOK and Assert.isNotOK
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
---
|
|
|
|
|
## Problem Explanation
|
2019-07-02 07:00:18 +10:00
|
|
|
To begin, locate the file "tests/1_unit_tests.js".
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-02 07:00:18 +10:00
|
|
|
This file contains multiple suites of tests for the project, and this challenge requires you to make the tests in ``` /** 3 */``` pass.
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
## Hints
|
|
|
|
|
|
|
|
|
|
### Hint 1
|
2019-07-02 07:00:18 +10:00
|
|
|
|
|
|
|
|
The lines in the test should be changed from `assert.fail()` to either `assert.isOk()` or `assert.isNotOk()`.
|
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
## Solutions
|
|
|
|
|
|
|
|
|
|
<details><summary>Solution 1 (Click to Show/Hide)</summary>
|
|
|
|
|
|
2019-07-02 07:00:18 +10:00
|
|
|
```js
|
|
|
|
|
/** 3 - Use assert.isOk() or assert.isNotOk() to make the tests pass. **/
|
|
|
|
|
// .isOk(truthy) and .isNotOk(falsey) will pass
|
2019-07-24 00:59:27 -07:00
|
|
|
test('#isOk, #isNotOk', function() {
|
|
|
|
|
assert.isNotOk(null, 'null is falsey');
|
|
|
|
|
assert.isOk("I'm truthy", 'a string is truthy');
|
|
|
|
|
assert.isOk(true, 'true is truthy');
|
2019-07-02 07:00:18 +10:00
|
|
|
});
|
2019-07-24 00:59:27 -07:00
|
|
|
```
|
|
|
|
|
</details>
|