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 (58 lines) | stat: -rw-r--r-- 966 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
var assert = require('assert')
var P = require('./index.js')
var a = { a: 1 }
var b = { b: 1 }

var t = require('../')
t.jobs = 64
process.env.TAP_BUFFER = 1

t.test(function removeFirstItem (t) {
  var p = new P
  p.add(a)
  p.add(b)
  p.remove(a)
  t.equal(p.length, 1)
  t.equal(p.head, p.tail)
  t.equal(p.head.data, b)
  t.end()
})

t.test(function removeTail (t) {
  var p = new P
  p.add(a)
  p.add(b)
  p.remove(b)
  t.equal(p.length, 1)
  t.equal(p.head, p.tail)
  t.equal(p.head.data, a)
  t.end()
})

t.test(function removeAll (t) {
  var p = new P
  p.add(a)
  p.add(b)
  p.remove(a)
  p.remove(b)
  t.equal(p.length, 0)
  t.equal(p.head, p.tail)
  t.equal(p.head, null)
  t.end()
})

t.test(function removeExtra (t) {
  var p = new P
  p.add(a)
  p.add(b)
  p.remove(b)
  p.remove({some: 'thing not in there'})
  p.remove(a)
  p.remove(a)
  p.remove(a)
  p.remove(a)
  t.equal(p.length, 0)
  t.equal(p.head, p.tail)
  t.equal(p.head, null)
  t.end()
})