source: trip-planner-front/node_modules/unique-filename/test/index.js@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 932 bytes
RevLine 
[6a3a178]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')
Note: See TracBrowser for help on using the repository browser.