UNPKG

2.1 kBPlain TextView Raw
1import * as Jimp from "jimp";
2
3const jimpInst: Jimp = new Jimp("test");
4
5// Main Jimp export should already have all of these already applied
6// $ExpectError
7jimpInst.read("Test");
8jimpInst.displace(jimpInst, 2);
9jimpInst.resize(40, 40);
10jimpInst.displace(jimpInst, 2);
11jimpInst.shadow((err, val, coords) => {});
12jimpInst.fishEye({ r: 12 });
13jimpInst.circle({ radius: 12, x: 12, y: 12 });
14// $ExpectError
15jimpInst.PNG_FILTER_NONE;
16
17// $ExpectError
18jimpInst.test;
19
20// $ExpectError
21jimpInst.func();
22
23// Main Jimp export should already have all of these already applied
24Jimp.read("Test");
25
26// $ExpectType 0
27Jimp.PNG_FILTER_NONE;
28
29// $ExpectError
30Jimp.test;
31
32// $ExpectError
33Jimp.func();
34
35test("can clone properly", async () => {
36 const baseImage = await Jimp.read("filename");
37 const cloneBaseImage = baseImage.clone();
38
39 // $ExpectType number
40 cloneBaseImage._deflateLevel;
41
42 test("can handle `this` returns on the core type properly", () => {
43 // $ExpectType number
44 cloneBaseImage.posterize(3)._quality;
45 });
46
47 test("can handle `this` returns properly", () => {
48 cloneBaseImage
49 .resize(1, 1)
50 .crop(0, 0, 0, 0)
51 .mask(cloneBaseImage, 2, 2)
52 .print("a" as any, 2, 2, "a" as any)
53 .resize(1, 1)
54 .quality(1)
55 .deflateLevel(2)._filterType;
56 });
57
58 test("can handle imageCallbacks `this` properly", () => {
59 cloneBaseImage.rgba(false, (_, jimpCBIn) => {
60 // $ExpectError
61 jimpCBIn.read("Test");
62 jimpCBIn.displace(jimpInst, 2);
63 jimpCBIn.resize(40, 40);
64 // $ExpectType number
65 jimpCBIn._filterType;
66
67 // $ExpectError
68 jimpCBIn.test;
69
70 // $ExpectError
71 jimpCBIn.func();
72 });
73 });
74});
75
76test("Can handle callback with constructor", () => {
77 const myBmpBuffer: Buffer = {} as any;
78
79 Jimp.read(myBmpBuffer, (err, cbJimpInst) => {
80 // $ExpectError
81 cbJimpInst.read("Test");
82 cbJimpInst.displace(jimpInst, 2);
83 cbJimpInst.resize(40, 40);
84 // $ExpectType number
85 cbJimpInst._filterType;
86
87 // $ExpectError
88 cbJimpInst.test;
89
90 // $ExpectError
91 cbJimpInst.func();
92 });
93});