Skip to content

Commit 46d2b54

Browse files
author
Edward Smit
committed
Merge pull request #28 from chaijs/feature/comments
Update comments
2 parents 96a4a77 + 47981f7 commit 46d2b54

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

index.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
var assert = chai.assert;
3131
var flag = utils.flag;
3232

33-
//check if we have all dependencies
33+
// check if we have all dependencies
3434
assert.ok(tv4Module, 'tv4 dependency');
3535
assert.ok(jsonpointer, 'jsonpointer dependency');
3636

37-
//export and use our own instance
37+
// export and use our own instance
3838
chai.tv4 = tv4Module.freshApi();
3939
chai.tv4.cyclicCheck = false;
4040
chai.tv4.banUnknown = false;
@@ -45,7 +45,7 @@
4545
}
4646
}
4747

48-
//make a compact debug string from any object
48+
// make a compact debug string from any object
4949
function valueStrim(value, cutoff) {
5050
var strimLimit = typeof cutoff === 'undefined' ? 60 : cutoff;
5151

@@ -87,13 +87,13 @@
8787
return label;
8888
}
8989

90-
//print validation errors
90+
// print validation errors
9191
var formatResult = function (error, data, schema, indent) {
9292
var schemaValue;
9393
var dataValue;
9494
var schemaLabel;
9595

96-
//assemble error string
96+
// assemble error string
9797
var ret = '';
9898
ret += '\n' + indent + error.message;
9999

@@ -110,7 +110,8 @@
110110
ret += '\n' + indent + ' field: ' + error.dataPath + ' -> ' + utils.type(dataValue) + ': ' + valueStrim(dataValue);
111111
}
112112

113-
//go deeper
113+
// sub errors are not implemented (yet?)
114+
// https://github.com/chaijs/chai-json-schema/issues/3
114115
/*if (error.subErrors) {
115116
forEachI(error.subErrors, function (error) {
116117
ret += formatResult(error, data, schema, indent + indent);
@@ -119,25 +120,25 @@
119120
return ret;
120121
};
121122

122-
//add the method
123+
// add the method
123124
chai.Assertion.addMethod('jsonSchema', function (schema, msg) {
124125
if (msg) {
125126
flag(this, 'message', msg);
126127
}
127128
var obj = this._obj;
128129

129-
//note: don't assert.ok(obj) -> zero or empty string is a valid and describable json-value
130+
// note: don't assert.ok(obj) -> zero or empty string is a valid and describable json-value
130131
assert.ok(schema, 'schema');
131132

132-
//single result
133+
// single result
133134
var result = chai.tv4.validateResult(obj, schema, chai.tv4.cyclicCheck, chai.tv4.banUnknown);
134-
//assertion fails on missing schemas
135+
// assertion fails on missing schemas
135136
var pass = result.valid && (result.missing.length === 0);
136137

137-
//assemble readable message
138+
// assemble readable message
138139
var label = extractSchemaLabel(schema, 30);
139140

140-
//assemble error report
141+
// assemble error report
141142
var details = '';
142143
if (!pass) {
143144
var indent = ' ';
@@ -162,7 +163,7 @@
162163
});
163164
}
164165
}
165-
//pass hardcoded strings and no actual value (mocha forces nasty string diffs)
166+
// pass hardcoded strings and no actual value (mocha forces nasty string diffs)
166167
this.assert(
167168
pass
168169
, 'expected value to match json-schema \'' + label + '\'' + details
@@ -171,7 +172,7 @@
171172
);
172173
});
173174

174-
//export tdd style
175+
// export tdd style
175176
assert.jsonSchema = function (val, exp, msg) {
176177
new chai.Assertion(val, msg).to.be.jsonSchema(exp);
177178
};

0 commit comments

Comments
 (0)