/
checked-file-test.js
75 lines (60 loc) · 1.94 KB
/
checked-file-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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
var buster = require('buster');
var assert = buster.assert;
var file = require('../lib/checked-file');
buster.testCase("checkedFile", {
"should be an object": function () {
assert.isObject(file);
},
"should have create method": function () {
assert.isFunction(file.create);
},
"when creating should complain about missing file name": function () {
assert.exception(function () {
file.create();
});
},
"when creating should complain about missing errors array": function () {
assert.exception(function () {
file.create("name");
});
},
"should expose file name": function () {
var f = file.create('file1.js', []);
assert.equals(f.name, 'file1.js');
},
"should expose errors": function () {
var errors = [{}, {}];
var f = file.create('', errors);
assert.equals(f.errors, errors);
},
"too many errors": {
"should look for trailing null": function () {
var f = file.create('', [{}, {}, null]);
assert.isTrue(f.tooManyErrors(), 'too many errors');
},
"should be false without trailing null": function () {
var f = file.create('', [{}, {}]);
assert.isFalse(f.tooManyErrors(), 'too many errors');
}
},
"errorDescription": {
setUp: function () {
this.assertErrorDescription = function (errors, desc) {
assert.equals(file.create('', errors).errorDescription(), desc);
};
},
"should be function": function () {
assert.isFunction(file.errorDescription);
},
"should return string describing number of errors": function () {
this.assertErrorDescription([], '0 errors');
this.assertErrorDescription([{}, {}], '2 errors');
},
"should pluralize properly": function () {
this.assertErrorDescription([{}], '1 error');
},
"should state if too many errors": function () {
this.assertErrorDescription([{}, null], 'more than 2 errors');
}
}
});