forked from ember-cli/ember-cli
/
assert-test.js
44 lines (35 loc) · 1.15 KB
/
assert-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
'use strict';
const { expect } = require('chai');
const { assert } = require('../../../lib/debug');
describe('assert', function () {
it('it throws when the description argument is missing', function () {
expect(() => {
assert();
}).to.throw('When calling `assert`, you must provide a description as the first argument.');
expect(() => {
assert('');
}).to.throw('When calling `assert`, you must provide a description as the first argument.');
});
it('it does nothing when the condition argument is truthy', function () {
expect(() => {
assert('description', 1);
}).to.not.throw();
expect(() => {
assert('description', {});
}).to.not.throw();
expect(() => {
assert('description', true);
}).to.not.throw();
});
it('it throws when the condition argument is falsy', function () {
expect(() => {
assert('description');
}).to.throw('ASSERTION FAILED: description');
expect(() => {
assert('description', null);
}).to.throw('ASSERTION FAILED: description');
expect(() => {
assert('description', false);
}).to.throw('ASSERTION FAILED: description');
});
});