Skip to content

Commit 3c28d1c

Browse files
authored
Merge pull request #165 from raszi/add-missing-test-orig
test: add missing tests
2 parents 2df2d04 + 8ec3b1e commit 3c28d1c

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

test/template-sync-test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* eslint-disable no-octal */
2+
// vim: expandtab:ts=2:sw=2
3+
4+
const
5+
assert = require('assert'),
6+
tmp = require('../lib/tmp');
7+
8+
describe('tmp', function () {
9+
describe('dirSync()', function () {
10+
it('with invalid template', function () {
11+
try {
12+
tmp.dirSync({template:'invalid'});
13+
} catch (err) {
14+
assert.equal(err.message, 'Invalid template provided', 'should have thrown the expected error');
15+
}
16+
});
17+
});
18+
19+
describe('fileSync()', function () {
20+
it('with invalid template', function () {
21+
try {
22+
tmp.fileSync({template:'invalid'});
23+
} catch (err) {
24+
assert.equal(err.message, 'Invalid template provided', 'should have thrown the expected error');
25+
}
26+
});
27+
});
28+
});

test/template-test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* eslint-disable no-octal */
2+
// vim: expandtab:ts=2:sw=2
3+
4+
const
5+
assert = require('assert'),
6+
tmp = require('../lib/tmp');
7+
8+
describe('tmp', function () {
9+
describe('dir()', function () {
10+
it('with invalid template', function (done) {
11+
tmp.dir({template:'invalid'}, function (err) {
12+
if (!err) return done(new Error('err expected'));
13+
try {
14+
assert.equal(err.message, 'Invalid template provided', 'should have thrown the expected error');
15+
} catch (err2) {
16+
done(err);
17+
}
18+
done();
19+
});
20+
});
21+
});
22+
23+
describe('file()', function () {
24+
it('with invalid template', function (done) {
25+
tmp.file({template:'invalid'}, function (err) {
26+
if (!err) return done(new Error('err expected'));
27+
try {
28+
assert.equal(err.message, 'Invalid template provided', 'should have thrown the expected error');
29+
} catch (err2) {
30+
done(err);
31+
}
32+
done();
33+
});
34+
});
35+
});
36+
});

0 commit comments

Comments
 (0)