Skip to content

Commit

Permalink
Merge pull request #438 from chriso/chriso/node-4-support
Browse files Browse the repository at this point in the history
Fix tests in node v4+
  • Loading branch information
chriso committed Oct 5, 2015
2 parents eecb88f + 37c7e72 commit 1813359
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sudo: false
language: node_js
node_js:
- "0.10"
- "0.12"
- "4.0"
- "4.1"
after_script:
- npm run coveralls
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ validator.isWhitespace('foo bar');

### Tests

Tests require node v4.0+.

- `make test` - run the test suite.
- `make test V=1` - run the test suite with added verbosity.
- `make test TEST=pattern` - run tests that match a pattern.
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"istanbul": "latest",
"jshint": "latest",
"uglify-js": "latest",
"coveralls": "latest",
"contextify": "latest"
"coveralls": "latest"
},
"scripts": {
"test": "node ./node_modules/.bin/_mocha --reporter spec",
Expand Down
15 changes: 7 additions & 8 deletions test/validators.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var validator = require('../validator')
, format = require('util').format
, contextify = require('contextify')
, assert = require('assert')
, path = require('path')
, fs = require('fs');
, fs = require('fs')
, vm = require('vm');

var validator_js = fs.readFileSync(path.join(__dirname, '../validator.js')).toString();

Expand Down Expand Up @@ -1270,17 +1270,16 @@ describe('Validators', function () {
}
};
window.define.amd = true;
var sandbox = contextify(window);
sandbox.run(validator_js);
sandbox.dispose();

var sandbox = vm.createContext(window);
vm.runInContext(validator_js, sandbox);
assert.equal(window.validator.trim(' foobar '), 'foobar');
});

it('should bind validator to the window if no module loaders are available', function () {
var window = {};
var sandbox = contextify(window);
sandbox.run(validator_js);
sandbox.dispose();
var sandbox = vm.createContext(window);
vm.runInContext(validator_js, sandbox);
assert.equal(window.validator.trim(' foobar '), 'foobar');
});

Expand Down

0 comments on commit 1813359

Please sign in to comment.