Нет описания

123456789101112131415161718192021222324252627282930313233343536
  1. var test = require('tape')
  2. var clone = require('./')
  3. var fs = require('fs')
  4. test('file', function(t) {
  5. compare(t, fs.statSync(__filename))
  6. t.end()
  7. })
  8. test('directory', function(t) {
  9. compare(t, fs.statSync(__dirname))
  10. t.end()
  11. })
  12. function compare(t, stat) {
  13. var copy = clone(stat)
  14. t.deepEqual(stat, copy, 'clone has equal properties')
  15. t.ok(stat instanceof fs.Stats, 'original is an fs.Stat')
  16. t.ok(copy instanceof fs.Stats, 'copy is an fs.Stat')
  17. ;['isDirectory'
  18. , 'isFile'
  19. , 'isBlockDevice'
  20. , 'isCharacterDevice'
  21. , 'isSymbolicLink'
  22. , 'isFIFO'
  23. , 'isSocket'
  24. ].forEach(function(method) {
  25. t.equal(
  26. stat[method].call(stat)
  27. , copy[method].call(copy)
  28. , 'equal value for stat.' + method + '()'
  29. )
  30. })
  31. }