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