Repository navigation
Expand file tree
/
Copy pathtemp.js
More file actions
65 lines (51 loc) · 1.73 KB
/
Copy pathtemp.js
File metadata and controls
65 lines (51 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
'use strict';
var requireWithNoCache = require('lib/utils').requireWithNoCache,
nodeTemp = require('temp');
describe('temp', function() {
var sandbox = sinon.sandbox.create(),
temp;
beforeEach(function() {
sandbox.stub(nodeTemp);
temp = requireWithNoCache(require.resolve('lib/temp'));
});
afterEach(function() {
sandbox.restore();
});
it('should enable auto clean', function() {
assert.calledOnce(nodeTemp.track);
});
describe('init', function() {
it('should create gemini temp dir in system temp dir by default', function() {
temp.init();
assert.calledWithMatch(nodeTemp.mkdirSync, {
dir: sinon.match.falsy,
prefix: '.gemini.tmp.'
});
});
it('should create gemini temp dir in passed dir', function() {
temp.init('./');
assert.calledWith(nodeTemp.mkdirSync, {
dir: process.cwd(),
prefix: '.gemini.tmp.'
});
});
it('should create gemini temp dir in passed absolute path', function() {
temp.init('/some/dir');
assert.calledWithMatch(nodeTemp.mkdirSync, {
dir: '/some/dir'
});
});
});
describe('path', function() {
it('should passthrough options extending them with temp dir', function() {
nodeTemp.mkdirSync.returns('/some/temp/dir');
temp.init();
temp.path({prefix: 'prefix.', suffix: '.suffix'});
assert.calledWith(nodeTemp.path, {
dir: '/some/temp/dir',
prefix: 'prefix.',
suffix: '.suffix'
});
});
});
});