Skip to content

Commit b0f7281

Browse files
committed
Rename spec, include test in lint.
All test files (except the ignored spec.js file) passing the lint test.
1 parent c9b3974 commit b0f7281

26 files changed

+68
-86
lines changed

Diff for: .jscsrc

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
"disallowSpaceAfterKeywords": false,
1212
"disallowSpaceBeforeBlockStatements": false,
1313
"disallowSpacesInsideObjectBrackets": null,
14-
"safeContextKeyword": "_this",
1514
"excludeFiles": [
16-
"test/**",
15+
"test/spec.js",
1716
"node_modules",
1817
"coverage",
1918
"doc",

Diff for: .jshintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
node_modules
2-
test
2+
test/spec.js
33
coverage
44
doc
55
async-validate.js

Diff for: test/fixtures/model.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var data = {
22
foo: {id: 'foo'},
3-
bar: {id: 'bar'},
3+
bar: {id: 'bar'}
44
}
55

66
// mock model class (vars)

Diff for: test/spec/additional.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('async-validate:', function() {
1515
name: 'Oops',
1616
street: 'Mock St',
1717
city: 'Mock City',
18-
zip: '12345678',
18+
zip: '12345678'
1919
}
2020
}
2121

@@ -36,7 +36,7 @@ describe('async-validate:', function() {
3636
address: {
3737
street: 'Mock St',
3838
city: 'Mock City',
39-
zip: '12345678',
39+
zip: '12345678'
4040
}
4141
}
4242
var schema = new Schema(descriptor);

Diff for: test/spec/assigned-rule.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
var expect = require('chai').expect
2-
, Schema = require('../../index')
1+
var Schema = require('../../index')
32
, descriptor = require('../fixtures/schema/assigned-rule');
43

54
describe('async-validate:', function() {
65

76
it('should access rule property from validator function', function(done) {
87
var schema = new Schema(descriptor);
9-
schema.validate({id: 'mock'}, function(err, res) {
8+
schema.validate({id: 'mock'}, function() {
109
done();
1110
});
1211
});

Diff for: test/spec/date.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var expect = require('chai').expect
55
, pattern = require('../fixtures/schema/date-pattern')
66
, range = require('../fixtures/schema/date-range');
77

8-
describe('async-validate:', function(done) {
8+
describe('async-validate:', function() {
99

1010
it('should error on invalid date value using a format', function(done) {
1111
var schema = new Schema(descriptor);

Diff for: test/spec/float.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var expect = require('chai').expect
44
describe('async-validate:', function() {
55

66
var descriptor = {
7-
ratio: {type: 'float'},
7+
ratio: {type: 'float'}
88
}
99

1010
it('should error when a number is not a float', function(done) {

Diff for: test/spec/function.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var expect = require('chai').expect
44
describe('async-validate:', function() {
55

66
var descriptor = {
7-
mock: {type: 'function'},
7+
mock: {type: 'function'}
88
}
99

1010
it('should error on value that is not a function', function(done) {
@@ -18,7 +18,7 @@ describe('async-validate:', function() {
1818

1919
it('should error on invalid arity (len: 1)', function(done) {
2020
var descriptor = {
21-
mock: {type: 'function', len: 1},
21+
mock: {type: 'function', len: 1}
2222
}
2323
var schema = new Schema(descriptor);
2424
schema.validate({mock: function(){}}, function(err, res) {
@@ -32,7 +32,7 @@ describe('async-validate:', function() {
3232

3333
it('should error on invalid arity (min: 1)', function(done) {
3434
var descriptor = {
35-
mock: {type: 'function', min: 1},
35+
mock: {type: 'function', min: 1}
3636
}
3737
var schema = new Schema(descriptor);
3838
schema.validate({mock: function(){}}, function(err, res) {
@@ -45,10 +45,10 @@ describe('async-validate:', function() {
4545

4646
it('should error on invalid arity (max: 0)', function(done) {
4747
var descriptor = {
48-
mock: {type: 'function', max: 0},
48+
mock: {type: 'function', max: 0}
4949
}
5050
var schema = new Schema(descriptor);
51-
schema.validate({mock: function(foo){}}, function(err, res) {
51+
schema.validate({mock: function(foo){foo();}}, function(err, res) {
5252
expect(res.errors.length).to.eql(1);
5353
expect(res.errors[0].message).to.eql(
5454
'mock cannot have more than 0 arguments');
@@ -58,10 +58,12 @@ describe('async-validate:', function() {
5858

5959
it('should error on invalid arity (min: 0, max: 1)', function(done) {
6060
var descriptor = {
61-
mock: {type: 'function', min: 0, max: 1},
61+
mock: {type: 'function', min: 0, max: 1}
6262
}
63-
var schema = new Schema(descriptor);
64-
schema.validate({mock: function(foo, bar){}}, function(err, res) {
63+
var schema = new Schema(descriptor)
64+
, source = {mock: function(foo, bar){foo();bar()}};
65+
66+
schema.validate(source, function(err, res) {
6567
expect(res.errors.length).to.eql(1);
6668
expect(res.errors[0].message).to.eql(
6769
'mock must have arguments length between 0 and 1');

Diff for: test/spec/instanceof.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe("async-validate:", function() {
1212
}
1313
}
1414
var validator = new schema(descriptor);
15-
validator.validate({instance: new Array()}, function(err, res) {
15+
validator.validate({instance: []}, function(err, res) {
1616
expect(res.errors.length).to.eql(1);
1717
expect(res.errors[0].message).to.eql(
1818
'instance is not an instance of Component');
@@ -27,7 +27,7 @@ describe("async-validate:", function() {
2727
}
2828
}
2929
var validator = new schema(descriptor);
30-
validator.validate({instance: new Array()}, function(err, res) {
30+
validator.validate({instance: []}, function(err, res) {
3131
expect(res.errors.length).to.eql(1);
3232
expect(res.errors[0].message).to.eql(
3333
'instance is not an instance of function (anonymous)');
@@ -47,7 +47,7 @@ describe("async-validate:", function() {
4747
}
4848
}
4949
var validator = new schema(descriptor);
50-
validator.validate({instance: new Array()}, function(err, res) {
50+
validator.validate({instance: []}, function(err, res) {
5151
expect(res.errors.length).to.eql(1);
5252
expect(res.errors[0].message).to.eql('instance is not a Component');
5353
done();

Diff for: test/spec/integer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var expect = require('chai').expect
44
describe('async-validate:', function() {
55

66
var descriptor = {
7-
port: {type: 'integer'},
7+
port: {type: 'integer'}
88
}
99

1010
it('should error on number not an integer', function(done) {

Diff for: test/spec/internal-error.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ describe('async-validate:', function() {
77
mock: function(cb) {
88
cb(new Error('query error'));
99
},
10-
next: function(cb) {
10+
next: function() {
1111
throw new Error('rule validation function invoked unexpectedly');
1212
}
1313
}
1414

1515
it('should callback with error', function(done) {
1616
var schema = new Schema(descriptor);
17-
schema.validate({}, function(err, res) {
17+
schema.validate({}, function(err) {
1818
function fn() {
1919
throw err;
2020
}

Diff for: test/spec/iterator.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("async-validate:", function() {
2424
function multiply(num, cb) {
2525
cb(new Error('mock error'));
2626
},
27-
function complete(err, results) {
27+
function complete(err) {
2828
function fn() {
2929
throw err;
3030
}
@@ -38,7 +38,7 @@ describe("async-validate:", function() {
3838
function multiply(num, cb) {
3939
cb(new Error('mock error'));
4040
},
41-
function complete(err, results) {
41+
function complete(err) {
4242
function fn() {
4343
throw err;
4444
}

Diff for: test/spec/length.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@ describe("async-validate:", function() {
55

66
it("should error on invalid string length", function(done) {
77
var descriptor = {
8-
name: {type: "string", len: 10},
8+
name: {type: "string", len: 10}
99
}
1010
var schema = new Schema(descriptor);
1111
schema.validate({name: "user"}, function(err, res) {
1212
expect(res.errors.length).to.eql(1);
13-
expect(res.errors[0].message).to.eql('name must be exactly 10 characters');
13+
expect(res.errors[0].message).to.eql(
14+
'name must be exactly 10 characters');
1415
done();
1516
});
1617
});
1718

1819
it("should error on invalid number length", function(done) {
1920
var descriptor = {
20-
port: {type: "number", len: 80},
21+
port: {type: "number", len: 80}
2122
}
2223
var schema = new Schema(descriptor);
2324
schema.validate({port: 8080}, function(err, res) {
@@ -29,19 +30,20 @@ describe("async-validate:", function() {
2930

3031
it("should error on invalid array length", function(done) {
3132
var descriptor = {
32-
roles: {type: "array", len: 2},
33+
roles: {type: "array", len: 2}
3334
}
3435
var schema = new Schema(descriptor);
3536
schema.validate({roles: ["user"]}, function(err, res) {
3637
expect(res.errors.length).to.eql(1);
37-
expect(res.errors[0].message).to.eql('roles must be exactly 2 in length');
38+
expect(res.errors[0].message).to.eql(
39+
'roles must be exactly 2 in length');
3840
done();
3941
});
4042
});
4143

4244
it("should validate string length", function(done) {
4345
var descriptor = {
44-
name: {type: "string", len: 8},
46+
name: {type: "string", len: 8}
4547
}
4648
var schema = new Schema(descriptor);
4749
schema.validate({name: "username"}, function(err, res) {
@@ -53,7 +55,7 @@ describe("async-validate:", function() {
5355

5456
it("should validate number length", function(done) {
5557
var descriptor = {
56-
port: {type: "number", len: 80},
58+
port: {type: "number", len: 80}
5759
}
5860
var schema = new Schema(descriptor);
5961
schema.validate({port: 80}, function(err, res) {
@@ -65,7 +67,7 @@ describe("async-validate:", function() {
6567

6668
it("should validate array length", function(done) {
6769
var descriptor = {
68-
roles: {type: "array", len: 2},
70+
roles: {type: "array", len: 2}
6971
}
7072
var schema = new Schema(descriptor);
7173
schema.validate({roles: ["user", "admin"]}, function(err, res) {

Diff for: test/spec/message-object.js

+9-17
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ var expect = require('chai').expect
33

44
describe('async-validate:', function() {
55

6-
it('should validate using a custom error message as min', function(done) {
7-
var descriptor = {
8-
num: {
9-
type: 'number', min: 0, max: 10,
10-
message: {
11-
min: 'Number may not be below zero',
12-
max: 'Number may not be above ten',
13-
}
6+
var descriptor = {
7+
num: {
8+
type: 'number', min: 0, max: 10,
9+
message: {
10+
min: 'Number may not be below zero',
11+
max: 'Number may not be above ten'
1412
}
1513
}
14+
}
15+
16+
it('should validate using a custom error message as min', function(done) {
1617
var validator = new schema(descriptor);
1718
validator.validate({num: -1}, function(err, res) {
1819
expect(res.errors[0].message).to.eql('Number may not be below zero');
@@ -21,15 +22,6 @@ describe('async-validate:', function() {
2122
});
2223

2324
it('should validate using a custom error message as max', function(done) {
24-
var descriptor = {
25-
num: {
26-
type: 'number', min: 0, max: 10,
27-
message: {
28-
min: 'Number may not be below zero',
29-
max: 'Number may not be above ten',
30-
}
31-
}
32-
}
3325
var validator = new schema(descriptor);
3426
validator.validate({num: 11}, function(err, res) {
3527
expect(res.errors[0].message).to.eql('Number may not be above ten');

Diff for: test/spec/messages.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('async-validate:', function() {
1111

1212
it('should validate using a custom error message', function(done) {
1313
var descriptor = {
14-
name: {type: 'string', required: true, message: 'Name is required'},
14+
name: {type: 'string', required: true, message: 'Name is required'}
1515
}
1616
var validator = new schema(descriptor);
1717
validator.validate({}, function(err, res) {
@@ -31,7 +31,7 @@ describe('async-validate:', function() {
3131
expect(parameters).to.be.an('array');
3232
return 'Name is required';
3333
}
34-
},
34+
}
3535
}
3636
var validator = new schema(descriptor);
3737
validator.validate({}, function(err, res) {
@@ -52,7 +52,7 @@ describe('async-validate:', function() {
5252
expect(parameters).to.be.an('array');
5353
return new Error('Name is required');
5454
}
55-
},
55+
}
5656
}
5757
var validator = new schema(descriptor);
5858
validator.validate({}, function(err, res) {
@@ -65,7 +65,7 @@ describe('async-validate:', function() {
6565

6666
it('should validate using custom messages', function(done) {
6767
var descriptor = {
68-
name: {type: 'string', required: true},
68+
name: {type: 'string', required: true}
6969
}
7070
var validator = new schema(descriptor);
7171

Diff for: test/spec/multiple.js renamed to test/spec/multiple-rules.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var expect = require('chai').expect
22
, Schema = require('../../index')
33
, email = /^.+@.+\..+/;
44

5-
describe('async-validate:', function(done) {
5+
describe('async-validate:', function() {
66

77
it('should error on multiple validation rules for a field',
88
function(done) {

Diff for: test/spec/multiple-types.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ var expect = require('chai').expect
33

44
describe('async-validate:', function() {
55

6-
function Component(){};
6+
function Component(){}
77

88
var descriptor = {
9-
prop: {type: [Boolean, 'string', Component, function(){}]},
9+
prop: {type: [Boolean, 'string', Component, function(){}]}
1010
}
1111

1212
var required = {
13-
prop: {type: [Boolean, 'string', Component, function(){}], required: true},
13+
prop: {type: [Boolean, 'string', Component, function(){}], required: true}
1414
}
1515

1616
it('should error on invalid type with multiple types array', function(done) {

0 commit comments

Comments
 (0)