Skip to content

Commit

Permalink
add initial suite of missing template tests
Browse files Browse the repository at this point in the history
  • Loading branch information
silkentrance committed Dec 7, 2017
1 parent cf037ec commit 430b7a1
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/template-sync-test.js
Original file line number Diff line number Diff line change
@@ -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');
}
});
});
});
37 changes: 37 additions & 0 deletions test/template-test.js
Original file line number Diff line number Diff line change
@@ -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();
});
});
});
});

0 comments on commit 430b7a1

Please sign in to comment.