File: test.js

package info (click to toggle)
node-tap 12.0.1+ds-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,916 kB
  • sloc: makefile: 84; sh: 75
file content (60 lines) | stat: -rw-r--r-- 1,284 bytes parent folder | download | duplicates (2)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
var exists = require('./')
var t = require('../')
var touch = { 'sync' : function (f) { var fs = require('fs') ;fs.closeSync(fs.openSync(f,'w')) ; } }
var rimraf = require('rimraf')

t.test('setup', function (t) {
  touch.sync('one')
  touch.sync('two')
  touch.sync('three')
  touch.sync('four')
  t.end()
})

t.test('existing file same way', function (t) {
  t.plan(4)
  t.ok(exists.sync('one'))
  t.ok(exists.sync('one'))
  exists('two', function (e) {
    t.ok(e)
    exists('two', t.ok)
  })
})

t.test('existing file different ways', function (t) {
  t.plan(4)
  t.ok(exists.sync('three'))
  t.ok(exists.sync('four'))
  exists('three', function (e) {
    t.ok(e)
    exists('four', t.ok)
  })
})

t.test('non-existing file same way', function (t) {
  t.plan(4)
  t.notOk(exists.sync('one-no'))
  t.notOk(exists.sync('one-no'))
  exists('two-no', function (e) {
    t.notOk(e)
    exists('two-no', t.notOk)
  })
})

t.test('non-existing file different ways', function (t) {
  t.plan(4)
  t.notOk(exists.sync('three-no'))
  t.notOk(exists.sync('four-no'))
  exists('three-no', function (e) {
    t.notOk(e)
    exists('four-no', t.notOk)
  })
})

t.test('cleanup', function (t) {
  rimraf.sync('one')
  rimraf.sync('two')
  rimraf.sync('three')
  rimraf.sync('four')
  t.end()
})