From 430b7a174d882d672e91f6e6b8ae203917313d5a Mon Sep 17 00:00:00 2001 From: Carsten Klein Date: Thu, 7 Dec 2017 22:29:57 +0100 Subject: [PATCH 1/7] add initial suite of missing template tests --- test/template-sync-test.js | 29 +++++++++++++++++++++++++++++ test/template-test.js | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 test/template-sync-test.js create mode 100644 test/template-test.js diff --git a/test/template-sync-test.js b/test/template-sync-test.js new file mode 100644 index 0000000..0a6a451 --- /dev/null +++ b/test/template-sync-test.js @@ -0,0 +1,29 @@ +/* eslint-disable no-octal */ +// vim: expandtab:ts=2:sw=2 + +const + assert = require('assert'), + inbandStandardTests = require('./name-inband-standard'), + tmp = require('../lib/tmp'); + + +describe('tmp', function () { + describe('dirSync()', function () { + it('with invalid template', function () { + try { + tmp.dirSync({template:'invalid'}); + } catch (err) { + assert.equal(err.message, 'Invalid template provided', 'should have thrown the expected error'); + } + }); + }); + describe('fileSync()', function () { + it('with invalid template', function () { + try { + tmp.fileSync({template:'invalid'}); + } catch (err) { + assert.equal(err.message, 'Invalid template provided', 'should have thrown the expected error'); + } + }); + }); +}); diff --git a/test/template-test.js b/test/template-test.js new file mode 100644 index 0000000..4f6e231 --- /dev/null +++ b/test/template-test.js @@ -0,0 +1,37 @@ +/* eslint-disable no-octal */ +// vim: expandtab:ts=2:sw=2 + +const + assert = require('assert'), + inbandStandardTests = require('./name-inband-standard'), + tmp = require('../lib/tmp'); + + +describe('tmp', function () { + describe('dir()', function () { + it('with invalid template', function (done) { + tmp.dir({template:'invalid'}, function (err, result) { + if (!err) return done(new Error('err expected')); + try { + assert.equal(err.message, 'Invalid template provided', 'should have thrown the expected error'); + } catch (err2) { + done(err); + } + done(); + }); + }); + }); + describe('file()', function () { + it('with invalid template', function (done) { + tmp.file({template:'invalid'}, function (err, result) { + if (!err) return done(new Error('err expected')); + try { + assert.equal(err.message, 'Invalid template provided', 'should have thrown the expected error'); + } catch (err2) { + done(err); + } + done(); + }); + }); + }); +}); From 0b3722271e6144a3847e570c10ef1605ed5ba32e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KARASZI=20Istv=C3=A1n?= Date: Wed, 27 Dec 2017 18:45:47 +0100 Subject: [PATCH 2/7] Remove unused variable assignment --- test/template-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/template-test.js b/test/template-test.js index 4f6e231..906423f 100644 --- a/test/template-test.js +++ b/test/template-test.js @@ -10,7 +10,7 @@ const describe('tmp', function () { describe('dir()', function () { it('with invalid template', function (done) { - tmp.dir({template:'invalid'}, function (err, result) { + tmp.dir({template:'invalid'}, function (err) { if (!err) return done(new Error('err expected')); try { assert.equal(err.message, 'Invalid template provided', 'should have thrown the expected error'); @@ -23,7 +23,7 @@ describe('tmp', function () { }); describe('file()', function () { it('with invalid template', function (done) { - tmp.file({template:'invalid'}, function (err, result) { + tmp.file({template:'invalid'}, function (err) { if (!err) return done(new Error('err expected')); try { assert.equal(err.message, 'Invalid template provided', 'should have thrown the expected error'); From b67f285e054f306b55b0e226fd1088e3d12aa8b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KARASZI=20Istv=C3=A1n?= Date: Wed, 27 Dec 2017 18:46:06 +0100 Subject: [PATCH 3/7] Remove unused require --- test/template-test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/template-test.js b/test/template-test.js index 906423f..74841cb 100644 --- a/test/template-test.js +++ b/test/template-test.js @@ -3,7 +3,6 @@ const assert = require('assert'), - inbandStandardTests = require('./name-inband-standard'), tmp = require('../lib/tmp'); From 00dc75335c48d8ab1e1b235f0b8880306dc59e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KARASZI=20Istv=C3=A1n?= Date: Wed, 27 Dec 2017 18:46:12 +0100 Subject: [PATCH 4/7] Remove unnecessary whitespace --- test/template-test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/template-test.js b/test/template-test.js index 74841cb..b1910c2 100644 --- a/test/template-test.js +++ b/test/template-test.js @@ -5,7 +5,6 @@ const assert = require('assert'), tmp = require('../lib/tmp'); - describe('tmp', function () { describe('dir()', function () { it('with invalid template', function (done) { From 9bbc7d87669695c9e6f8c97fb4c6f58b71dd9317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KARASZI=20Istv=C3=A1n?= Date: Wed, 27 Dec 2017 18:46:24 +0100 Subject: [PATCH 5/7] Add missing whitespace --- test/template-test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/template-test.js b/test/template-test.js index b1910c2..339f51a 100644 --- a/test/template-test.js +++ b/test/template-test.js @@ -19,6 +19,7 @@ describe('tmp', function () { }); }); }); + describe('file()', function () { it('with invalid template', function (done) { tmp.file({template:'invalid'}, function (err) { From 17e568ae5dc2d99630731f3006dbee73191a1182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KARASZI=20Istv=C3=A1n?= Date: Wed, 27 Dec 2017 18:47:07 +0100 Subject: [PATCH 6/7] Remove unused require --- test/template-sync-test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/template-sync-test.js b/test/template-sync-test.js index 0a6a451..23dae3a 100644 --- a/test/template-sync-test.js +++ b/test/template-sync-test.js @@ -3,7 +3,6 @@ const assert = require('assert'), - inbandStandardTests = require('./name-inband-standard'), tmp = require('../lib/tmp'); From 8ec3b1e92be4259f4ca322ac256dc4d30608c553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KARASZI=20Istv=C3=A1n?= Date: Wed, 27 Dec 2017 18:47:13 +0100 Subject: [PATCH 7/7] Whitespace fixes --- test/template-sync-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/template-sync-test.js b/test/template-sync-test.js index 23dae3a..a0e7b39 100644 --- a/test/template-sync-test.js +++ b/test/template-sync-test.js @@ -5,7 +5,6 @@ const assert = require('assert'), tmp = require('../lib/tmp'); - describe('tmp', function () { describe('dirSync()', function () { it('with invalid template', function () { @@ -16,6 +15,7 @@ describe('tmp', function () { } }); }); + describe('fileSync()', function () { it('with invalid template', function () { try {