forked from steakwallet/airdrops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.test.ts
45 lines (38 loc) · 867 Bytes
/
data.test.ts
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
import fs from "fs";
import drops from "./data/drops.json";
const NOW = new Date();
const requiredProperties = [
"network",
"name",
"symbol",
"announcementLink",
"ecosystems",
"homeLink",
];
function verify(drop: any) {
const missing = requiredProperties.find((prop) => !drop[prop]);
if (missing) {
return `Missing ${missing}`;
}
if (
drop.startDate &&
new Date(drop.startDate).getTime() < NOW.getTime() &&
!drop.claimLink
) {
return "Invalid claim link";
}
if (
!fs.existsSync(`./public/images/${drop.symbol.toLowerCase()}.png`) &&
!fs.existsSync(`./public/images/${drop.network.toLowerCase()}.png`)
) {
return "Missing image";
}
return true;
}
describe("verifies data.json", () => {
drops.forEach((drop) => {
it(drop.name, () => {
expect(verify(drop)).toBe(true);
});
});
});