-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
72 lines (64 loc) · 1.71 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
72
const test = require("flug");
const write = require("./index.js");
const data = {
xScale: 2445.9849051249894,
ySkew: 0,
xSkew: 0,
yScale: -2445.98490512499,
xOrigin: 7699959.850241235,
yOrigin: 1323859.6754601842
};
test("default", ({ eq }) => {
eq(write(data), "2445.9849051249894\n0\n0\n-2445.98490512499\n7699959.850241235\n1323859.6754601842\n");
});
test("write numerical strings", ({ eq }) => {
eq(
write({
...data,
xScale: "2445.9849051249894123456789"
}),
"2445.9849051249894123456789\n0\n0\n-2445.98490512499\n7699959.850241235\n1323859.6754601842\n"
);
});
test("custom sep", ({ eq }) => {
eq(write(data, { sep: "\r\n" }), "2445.9849051249894\r\n0\r\n0\r\n-2445.98490512499\r\n7699959.850241235\r\n1323859.6754601842\r\n");
});
test("undefined", ({ eq }) => {
let error;
try {
write(undefined);
} catch (e) {
error = e;
}
eq(error.message, "[wld-writer] can't write a world file without data!");
});
test("null", ({ eq }) => {
let error;
try {
write(undefined);
} catch (e) {
error = e;
}
eq(error.message, "[wld-writer] can't write a world file without data!");
});
test("xSkew = null", ({ eq }) => {
let error;
try {
write({ ...data, xSkew: null });
} catch (e) {
error = e;
}
eq(error.message, "[wld-writer] xSkew is null");
});
test("write super precise numbers", ({ eq }) => {
const data = {
xScale: "2445.9849051249894000077777777777777",
ySkew: 0,
xSkew: 0,
yScale: -2445.98490512499,
xOrigin: 7699959.850241235,
yOrigin: 1323859.6754601842
};
const written = write(data);
eq(written, "2445.9849051249894000077777777777777\n0\n0\n-2445.98490512499\n7699959.850241235\n1323859.6754601842\n");
});