您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

index.js 932B

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