Skip to content

Commit

Permalink
update deps and test on node 11
Browse files Browse the repository at this point in the history
  • Loading branch information
cjihrig committed Oct 23, 2018
1 parent 0dfe00e commit 03d7b92
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ language: node_js

node_js:
- "8"
- "9"
- "10"
- "11"
- "node"

sudo: false
20 changes: 10 additions & 10 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ internals.addMethod = function (names, fn) {
internals.addMethod(word, method);
});

internals.addMethod('error', function (/*type, message*/) {
internals.addMethod('error', function (...args /*type, message*/) {

const type = arguments.length && typeof arguments[0] !== 'string' && !(arguments[0] instanceof RegExp) ? arguments[0] : Error;
const lastArg = arguments[1] || arguments[0];
const type = args.length && typeof args[0] !== 'string' && !(args[0] instanceof RegExp) ? args[0] : Error;
const lastArg = args[1] || args[0];
const message = typeof lastArg === 'string' || lastArg instanceof RegExp ? lastArg : null;
const err = this._ref;

Expand Down Expand Up @@ -366,13 +366,13 @@ internals.satisfy = function (validator) {
internals.addMethod(['satisfy', 'satisfies'], internals.satisfy);


internals.throw = function (/* type, message */) {
internals.throw = function (...args /* type, message */) {

internals.assert(this, typeof this._ref === 'function', 'Can only assert throw on functions');
internals.assert(this, !this._flags.not || !arguments.length, 'Cannot specify arguments when expecting not to throw');
internals.assert(this, !this._flags.not || !args.length, 'Cannot specify arguments when expecting not to throw');

const type = arguments.length && typeof arguments[0] !== 'string' && !(arguments[0] instanceof RegExp) ? arguments[0] : null;
const lastArg = arguments[1] || arguments[0];
const type = args.length && typeof args[0] !== 'string' && !(args[0] instanceof RegExp) ? args[0] : null;
const lastArg = args[1] || args[0];
const message = typeof lastArg === 'string' || lastArg instanceof RegExp ? lastArg : null;

let thrown = false;
Expand Down Expand Up @@ -402,13 +402,13 @@ internals.throw = function (/* type, message */) {
internals.addMethod(['throw', 'throws'], internals.throw);


internals.reject = async function (/* type, message */) {
internals.reject = async function (...args/* type, message */) {

try {
internals.assert(this, internals.isPromise(this._ref), 'Can only assert reject on promises');

const type = arguments.length && typeof arguments[0] !== 'string' && !(arguments[0] instanceof RegExp) ? arguments[0] : null;
const lastArg = arguments[1] || arguments[0];
const type = args.length && typeof args[0] !== 'string' && !(args[0] instanceof RegExp) ? args[0] : null;
const lastArg = args[1] || args[0];
const message = typeof lastArg === 'string' || lastArg instanceof RegExp ? lastArg : null;

let thrown = null;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"hoek": "5.x.x"
},
"devDependencies": {
"lab": "15.x.x",
"lab": "17.x.x",
"markdown-toc": "1.1.x"
},
"scripts": {
Expand Down
13 changes: 7 additions & 6 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ describe('expect()', () => {
}

Code.settings.comparePrototypes = origPrototype;
Hoek.assert(exception2.message === 'Expected {} to equal specified value: {}', exception2);
Hoek.assert(exception2.message === `Expected {} to equal specified value: ${Util.format(Object.create(null))}`, exception2);
});

describe('assertion', () => {
Expand All @@ -322,7 +322,7 @@ describe('expect()', () => {

const grab = function () {

return arguments;
return arguments; // eslint-disable-line prefer-rest-params
};

try {
Expand Down Expand Up @@ -407,7 +407,7 @@ describe('expect()', () => {
it('validates correct type', () => {

try {
Code.expect(new Buffer([1])).to.be.a.buffer();
Code.expect(Buffer.from([1])).to.be.a.buffer();
}
catch (err) {
var exception = err;
Expand Down Expand Up @@ -759,7 +759,7 @@ describe('expect()', () => {
it('invalidates incorrect type', () => {

try {
Code.expect(new Buffer([20])).to.be.an.object();
Code.expect(Buffer.from([20])).to.be.an.object();
}
catch (err) {
var exception = err;
Expand Down Expand Up @@ -1054,6 +1054,7 @@ describe('expect()', () => {
catch (err) {
var exception1 = err;
}

Hoek.assert(exception1.message === 'Can only assert include with a single parameter', exception1);

try {
Expand Down Expand Up @@ -1239,7 +1240,7 @@ describe('expect()', () => {
it('validates buffer', () => {

try {
Code.expect(new Buffer('')).to.be.empty();
Code.expect(Buffer.from('')).to.be.empty();
}
catch (err) {
var exception = err;
Expand Down Expand Up @@ -1302,7 +1303,7 @@ describe('expect()', () => {
it('validates buffer', () => {

try {
Code.expect(new Buffer('a')).to.have.length(1);
Code.expect(Buffer.from('a')).to.have.length(1);
}
catch (err) {
var exception = err;
Expand Down

0 comments on commit 03d7b92

Please sign in to comment.