Skip to content

Commit

Permalink
test: require Node.js 10
Browse files Browse the repository at this point in the history
Bump devs
  • Loading branch information
forresst committed Feb 27, 2020
1 parent 828d7a4 commit 5dc1883
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 23 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"index.js"
],
"engines": {
"node": ">=8"
"node": ">=10"
},
"scripts": {
"test": "xo && nyc ava"
Expand All @@ -37,19 +37,19 @@
"hidden"
],
"dependencies": {
"make-dir": "^3.0.0"
"make-dir": "^3.0.2"
},
"devDependencies": {
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"ava": "^2.3.0",
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"ava": "^3.4.0",
"coveralls": "^3.0.6",
"husky": "^3.0.5",
"husky": "^4.2.3",
"markdown-magic": "^1.0.0",
"markdown-magic-package-json": "^2.0.1",
"mock-fs": "^4.10.1",
"nyc": "^14.1.1",
"xo": "^0.25.3"
"mock-fs": "^4.11.0",
"nyc": "^15.0.0",
"xo": "^0.27.2"
},
"nyc": {
"reporter": [
Expand Down
20 changes: 15 additions & 5 deletions test/test-filesystemerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ test('Read async file when permission denied', async t => {
test('Read sync file when permission denied', t => {
const error = t.throws(() => {
amunet.readSync('/test/directory/file-denied.txt');
}, Error);
}, {
instanceOf: Error
});
t.is(error.code, 'EACCES');
});

Expand All @@ -45,7 +47,9 @@ test('Write async file when permission denied', async t => {
test('Write sync file when permission denied', t => {
const error = t.throws(() => {
amunet.writeSync('/test/directory/file-denied.txt');
}, Error);
}, {
instanceOf: Error
});
t.is(error.code, 'EACCES');
});

Expand All @@ -57,7 +61,9 @@ test('Read async file in directory permission denied', async t => {
test('Read sync file in directory permission denied', t => {
const error = t.throws(() => {
amunet.readSync('/test/directory-denied/file-in-denied-directory.txt');
}, Error);
}, {
instanceOf: Error
});
t.is(error.code, 'EACCES');
});

Expand All @@ -69,7 +75,9 @@ test('Write async file in directory permission denied', async t => {
test('Write sync file in directory permission denied', t => {
const error = t.throws(() => {
amunet.writeSync('/test/directory-denied/file-in-denied-directory.txt');
}, Error);
}, {
instanceOf: Error
});
t.is(error.code, 'EACCES');
});

Expand All @@ -81,6 +89,8 @@ test('Write async file in sub-directory of directory permission denied', async t
test('Write sync file in sub-directory of directory permission denied', t => {
const error = t.throws(() => {
amunet.writeSync('/test/directory-denied/sub-dir/file.txt');
}, Error);
}, {
instanceOf: Error
});
t.is(error.code, 'EACCES');
});
10 changes: 8 additions & 2 deletions test/test-parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ const getRemoteMetadata = url => new Promise((resolve, reject) => {
test('The `parse` function without arguments should throw an error', t => {
t.throws(() => {
parse();
}, /Expected the `input` argument to be of type `String`, got `undefined`/);
}, {
instanceOf: TypeError,
message: 'Expected the `input` argument to be of type `String`, got `undefined`'
});
});

test('If the argument of the `parse` function is not a String it should throw an error', t => {
t.throws(() => {
parse({});
}, /Expected the `input` argument to be of type `String`, got `object`/);
}, {
instanceOf: TypeError,
message: 'Expected the `input` argument to be of type `String`, got `object`'
});
});

test('The `parse` function with an empty string argument should return an empty object', async t => {
Expand Down
20 changes: 16 additions & 4 deletions test/test-stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,37 @@ const {stringify} = require('..');
test('The `stringify` function without arguments should throw an error', t => {
t.throws(() => {
stringify();
}, /Expected the `input` argument to be of type `String`, got `undefined`/);
}, {
instanceOf: TypeError,
message: 'Expected the `input` argument to be of type `String`, got `undefined`'
});
});

test('If the first argument of the `stringify` function is not a string, an error should be thrown', t => {
t.throws(() => {
stringify({});
}, /Expected the `input` argument to be of type `String`, got `object`/);
}, {
instanceOf: TypeError,
message: 'Expected the `input` argument to be of type `String`, got `object`'
});
});

test('The `stringify` function with one argument should throw an error', t => {
t.throws(() => {
stringify('');
}, /Expected the `objectAfter` argument to be of type `Object`, got `undefined`/);
}, {
instanceOf: TypeError,
message: 'Expected the `objectAfter` argument to be of type `Object`, got `undefined`'
});
});

test('If the second argument of the `stringify` function is not a object, an error should be thrown', t => {
t.throws(() => {
stringify('', '');
}, /Expected the `objectAfter` argument to be of type `Object`, got `string`/);
}, {
instanceOf: TypeError,
message: 'Expected the `objectAfter` argument to be of type `Object`, got `string`'
});
});

test('The `stringify` function without metadata should return a empty string', t => {
Expand Down
12 changes: 9 additions & 3 deletions test/test-writesync.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ test('Write sync into new file with createFileUnknown: false', t => {
const filePath = path.join(outputDir, 'write-sync-new-file-option-false.md');
const error = t.throws(() => {
writeSync(filePath, {a: '1', b: '2'}, {createFileUnknown: false});
}, Error);
}, {
instanceOf: Error
});
t.is(error.code, 'ENOENT');
});

Expand All @@ -53,15 +55,19 @@ test('Write sync into new file in folder unknown with createFolderUnknown: false
const filePath = path.join(outputDir, 'unknownFolder2', 'write-sync-unknown-folder-option-false.md');
const error = t.throws(() => {
writeSync(filePath, {a: '1', b: '2'}, {createFolderUnknown: false});
}, Error);
}, {
instanceOf: Error
});
t.is(error.code, 'ENOENT');
});

test('Write sync into new file in folder unknown with createFolderUnknown: false, createFileUnknown: false', t => {
const filePath = path.join(outputDir, 'unknownFolder3', 'write-sync-unknown-folder-option-all-false.md');
const error = t.throws(() => {
writeSync(filePath, {a: '1', b: '2'}, {createFolderUnknown: false, createFileUnknown: false});
}, Error);
}, {
instanceOf: Error
});
t.is(error.code, 'ENOENT');
});

Expand Down

0 comments on commit 5dc1883

Please sign in to comment.