File: test.js

package info (click to toggle)
node-clone-stats 1.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 80 kB
  • sloc: javascript: 40; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 757 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var test = require('tape')
var clone = require('./')
var fs = require('fs')

test('file', function(t) {
  compare(t, fs.statSync(__filename))
  t.end()
})

test('directory', function(t) {
  compare(t, fs.statSync(__dirname))
  t.end()
})

function compare(t, stat) {
  var copy = clone(stat)

  t.deepEqual(stat, copy, 'clone has equal properties')
  t.ok(stat instanceof fs.Stats, 'original is an fs.Stat')
  t.ok(copy instanceof fs.Stats, 'copy is an fs.Stat')

  ;['isDirectory'
  , 'isFile'
  , 'isBlockDevice'
  , 'isCharacterDevice'
  , 'isSymbolicLink'
  , 'isFIFO'
  , 'isSocket'
  ].forEach(function(method) {
    t.equal(
        stat[method].call(stat)
      , copy[method].call(copy)
      , 'equal value for stat.' + method + '()'
    )
  })
}