-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
47 lines (44 loc) · 1.07 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
const nanoS3 = require('./')
const test = require('tape')
test('required keys', t => {
t.plan(2)
nanoS3(null, err => {
t.ok(err, 'Returns Error on missing params')
t.ok(/^Missing required option/.test(err.message), err.message)
})
})
test('required types', t => {
t.plan(2)
nanoS3({
protocol: 0,
host: 0,
bucket: 0,
accessKeyId: 0,
secretAccessKey: 0,
maxFileSize: '1',
filename: 0,
path: 0,
contentType: 0,
data: 'x'
}, err => {
t.ok(err, 'Returns Error on missing params')
t.ok(/^Invalid option/.test(err.message), err.message)
})
})
test('works?', t => {
t.plan(3)
nanoS3({
protocol: 'https',
host: 's3.amazonaws.com',
bucket: 'nano-s3-test-bad-bucket',
accessKeyId: 'xyz789',
secretAccessKey: 'abc123',
filename: 'badfile.txt',
contentType: 'text/plain',
data: Buffer.from('plain text\n')
}, (err, res) => {
t.error(err, 'No Error No Cry')
t.equals(res.statusCode, 403, 'good status (403)')
t.equals(res.statusMessage, 'Forbidden', 'good message (Forbidden)')
})
})