-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.js
71 lines (60 loc) · 1.96 KB
/
test.js
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
61
62
63
64
65
66
67
68
69
70
71
var fs = require('fs')
var test = require('tape')
var hyperdrive = require('hyperdrive')
var ram = require('random-access-memory')
var isDuplicate = require('.')
test('duplicate with same name', function (t) {
var archive = hyperdrive(ram)
archive.writeFile('example.js', fs.readFileSync('example.js'), function (err) {
t.ifError(err)
isDuplicate(archive, 'example.js', function (err, duplicate) {
t.ifError(err)
t.ok(duplicate, 'example.js is duplicate')
t.end()
})
})
})
test('duplicate with different name', function (t) {
var archive = hyperdrive(ram)
archive.writeFile('different.js', fs.readFileSync('example.js'), function (err) {
t.ifError(err)
isDuplicate(archive, 'example.js', 'different.js', function (err, duplicate) {
t.ifError(err)
t.ok(duplicate, 'example.js is duplicate of different.js')
t.end()
})
})
})
test('file not in archive', function (t) {
var archive = hyperdrive(ram)
archive.writeFile('example.js', fs.readFileSync('example.js'), function (err) {
t.ifError(err)
isDuplicate(archive, 'index.js', function (err, duplicate) {
t.ifError(err)
t.notOk(duplicate, 'index.js is not a duplicate')
t.end()
})
})
})
test('not duplicate of file in archive', function (t) {
var archive = hyperdrive(ram)
archive.writeFile('example.js', fs.readFileSync('example.js'), function (err) {
t.ifError(err)
isDuplicate(archive, 'example.js', 'index.js', function (err, duplicate) {
t.ifError(err)
t.notOk(duplicate, 'index.js is not a duplicate')
t.end()
})
})
})
test('not duplicate of file in archive other way', function (t) {
var archive = hyperdrive(ram)
archive.writeFile('example.js', fs.readFileSync('example.js'), function (err) {
t.ifError(err)
isDuplicate(archive, 'index.js', 'example.js', function (err, duplicate) {
t.ifError(err)
t.notOk(duplicate, 'index.js is not a duplicate')
t.end()
})
})
})