-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathuploader.test.js
73 lines (64 loc) · 1.86 KB
/
uploader.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
72
73
const uploader = require("./uploader");
jest.setTimeout(240000);
const options = {
path: "",
service: "ipfs",
host: "ipfs.infura.io",
port: 5001,
protocol: "https",
timeout: 1000,
verbose: false,
};
describe("ipfs", () => {
it("throws ENOENT: no such file or directory", async () => {
await expect(
uploader.upload({ ...options, path: "./1" })
).rejects.toThrow();
});
it.skip("throws multipart: NextPart: EOF", async () => {
await expect(
uploader.upload({ ...options, path: "./data_empty" })
).rejects.toThrow("multipart: NextPart: EOF");
});
});
describe("infura", () => {
it("throws ENOENT: no such file or directory", async () => {
await expect(
uploader.upload({ ...options, path: "./1", service: "infura" })
).rejects.toThrow();
});
});
describe("pinata", () => {
it("throws error when pinataKey is empty", async () => {
await expect(
uploader.upload({ ...options, path: "./data", service: "pinata" })
).rejects.toThrow("[pinata] Key is empty. (input `pinataKey`)");
});
it("throws error when pinataSecret is empty", async () => {
await expect(
uploader.upload({
...options,
path: "./data",
service: "pinata",
pinataKey: ".",
})
).rejects.toThrow("[pinata] Secret is empty");
});
});
describe("filebase", () => {
it("throws error when filebaseKey is empty", async () => {
await expect(
uploader.upload({ ...options, path: "./data", service: "filebase" })
).rejects.toThrow("[filebase] Key is empty. (input `filebaseKey`)");
});
it("throws error when filebaseSecret is empty", async () => {
await expect(
uploader.upload({
...options,
path: "./data",
service: "filebase",
filebaseKey: ".",
})
).rejects.toThrow("[filebase] Secret is empty. (input `filebaseSecret`)");
});
});