Skip to content

Commit

Permalink
Lint tests
Browse files Browse the repository at this point in the history
  • Loading branch information
forabi committed Feb 16, 2016
1 parent 8b84882 commit 369b753
Show file tree
Hide file tree
Showing 7 changed files with 3,052 additions and 2,944 deletions.
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
validator.js
validator.min.js
test
validator.min.js
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"uglify-js": "latest"
},
"scripts": {
"lint": "eslint src",
"lint": "eslint src test",
"clean:node": "rm -rf index.js lib",
"clean:browser": "rm -rf validator*.js",
"clean": "npm run clean:node && npm run clean:browser",
Expand Down
4 changes: 3 additions & 1 deletion test/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"rules": {
"no-var": 0,
"vars-on-top": 0,
"prefer-arrow-callback": 0
"prefer-arrow-callback": 0,
"object-shorthand": [0],
"quote-props": 0
}
}
41 changes: 21 additions & 20 deletions test/client-side.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
var assert = require('assert')
, validator = require('../validator')
, min = require('../validator.min');
var assert = require('assert');
var validator = require('../validator');
var min = require('../validator.min');

describe('Minified version', function () {
it('should export the same things as the server-side version', function () {
for (var key in validator) {
if ({}.hasOwnProperty.call(validator, key)) {
assert.equal(typeof validator[key],
typeof min[key], 'Minified version did not export ' + key);
}
}
});

it('should export the same things as the server-side version', function () {
for (var key in validator) {
assert.equal(typeof validator[key], typeof min[key], 'Minified version did not export ' + key);
}
});
it('should be up to date', function () {
assert.equal(min.version, validator.version, 'Minified version mismatch. Run `make min`');
});

it('should be up to date', function () {
assert.equal(min.version, validator.version, 'Minified version mismatch. Run `make min`');
});

it('should validate strings', function () {
assert.equal(min.isEmail('[email protected]'), true);
assert.equal(min.isEmail('foo'), false);
});

it('should sanitize strings', function () {
assert.equal(min.toBoolean('1'), true);
});
it('should validate strings', function () {
assert.equal(min.isEmail('[email protected]'), true);
assert.equal(min.isEmail('foo'), false);
});

it('should sanitize strings', function () {
assert.equal(min.toBoolean('1'), true);
});
});
30 changes: 14 additions & 16 deletions test/exports.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
var assert = require('assert')
, validator = require('../index');
var assert = require('assert');
var validator = require('../index');

describe('Exports', function () {
it('should export validators', function () {
assert.equal(typeof validator.isEmail, 'function');
assert.equal(typeof validator.isAlpha, 'function');
});

it('should export validators', function () {
assert.equal(typeof validator.isEmail, 'function');
assert.equal(typeof validator.isAlpha, 'function');
});

it('should export sanitizers', function () {
assert.equal(typeof validator.toBoolean, 'function');
assert.equal(typeof validator.toFloat, 'function');
});

it('should export the version number', function () {
assert.equal(validator.version, require('../package.json').version,
'Version number mismatch in "package.json" vs. "validator.js"');
});
it('should export sanitizers', function () {
assert.equal(typeof validator.toBoolean, 'function');
assert.equal(typeof validator.toFloat, 'function');
});

it('should export the version number', function () {
assert.equal(validator.version, require('../package.json').version,
'Version number mismatch in "package.json" vs. "validator.js"');
});
});
Loading

0 comments on commit 369b753

Please sign in to comment.