1
|
'sue strict'
|
2
|
var t = require('tap')
|
3
|
var uniqueFilename = require('../index.js')
|
4
|
|
5
|
t.plan(6)
|
6
|
|
7
|
var randomTmpfile = uniqueFilename('tmp')
|
8
|
t.like(randomTmpfile, /^tmp.[a-f0-9]{8}$/, 'random tmp file')
|
9
|
|
10
|
var randomAgain = uniqueFilename('tmp')
|
11
|
t.notEqual(randomAgain, randomTmpfile, 'random tmp files are not the same')
|
12
|
|
13
|
var randomPrefixedTmpfile = uniqueFilename('tmp', 'my-test')
|
14
|
t.like(randomPrefixedTmpfile, /^tmp.my-test-[a-f0-9]{8}$/, 'random prefixed tmp file')
|
15
|
|
16
|
var randomPrefixedAgain = uniqueFilename('tmp', 'my-test')
|
17
|
t.notEqual(randomPrefixedAgain, randomPrefixedTmpfile, 'random prefixed tmp files are not the same')
|
18
|
|
19
|
var uniqueTmpfile = uniqueFilename('tmp', 'testing', '/my/thing/to/uniq/on')
|
20
|
t.like(uniqueTmpfile, /^tmp.testing-7ddd44c0$/, 'unique filename')
|
21
|
|
22
|
var uniqueAgain = uniqueFilename('tmp', 'testing', '/my/thing/to/uniq/on')
|
23
|
t.is(uniqueTmpfile, uniqueAgain, 'same unique string component produces same filename')
|