dcmjs 0.34.2 → 0.34.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +4 -0
- package/.github/workflows/lint-and-format.yml +27 -0
- package/.github/workflows/tests.yml +2 -2
- package/build/dcmjs.es.js +4103 -4093
- package/build/dcmjs.es.js.map +1 -1
- package/build/dcmjs.js +4103 -4093
- package/build/dcmjs.js.map +1 -1
- package/package.json +3 -2
- package/test/adapters.test.js +14 -16
- package/test/data-encoding.test.js +1 -4
- package/test/data-options.test.js +0 -1
- package/test/data.test.js +224 -117
- package/test/lossless-read-write.test.js +430 -250
- package/test/testUtils.js +1 -2
- package/test/utilities/deepEqual.test.js +29 -20
package/test/testUtils.js
CHANGED
|
@@ -29,7 +29,6 @@ function unzip(zipFilePath, targetPath) {
|
|
|
29
29
|
try {
|
|
30
30
|
// reading archives
|
|
31
31
|
var zip = new AdmZip(zipFilePath);
|
|
32
|
-
var zipEntries = zip.getEntries(); // an array of ZipEntry records
|
|
33
32
|
// extracts everything
|
|
34
33
|
zip.extractAllTo(targetPath, true);
|
|
35
34
|
resolve();
|
|
@@ -76,7 +75,7 @@ async function getTestDataset(url, filename) {
|
|
|
76
75
|
let filePromise = asyncDownloadMap.get(targetPath);
|
|
77
76
|
if (!filePromise && !fs.existsSync(targetPath)) {
|
|
78
77
|
filePromise = downloadToFile(url, targetPath);
|
|
79
|
-
asyncDownloadMap.set(targetPath,filePromise);
|
|
78
|
+
asyncDownloadMap.set(targetPath, filePromise);
|
|
80
79
|
}
|
|
81
80
|
// This returns immediately if filePromise is undefined - eg if the file already downloaded.
|
|
82
81
|
await filePromise;
|
|
@@ -1,78 +1,87 @@
|
|
|
1
1
|
import { deepEqual } from "../../src/utilities/deepEqual";
|
|
2
2
|
|
|
3
|
-
describe(
|
|
4
|
-
test(
|
|
3
|
+
describe("deepEqual", () => {
|
|
4
|
+
test("returns true for identical primitives", () => {
|
|
5
5
|
expect(deepEqual(42, 42)).toBe(true);
|
|
6
|
-
expect(deepEqual(
|
|
6
|
+
expect(deepEqual("hello", "hello")).toBe(true);
|
|
7
7
|
expect(deepEqual(true, true)).toBe(true);
|
|
8
8
|
expect(deepEqual(null, null)).toBe(true);
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
test(
|
|
11
|
+
test("returns false for different primitives", () => {
|
|
12
12
|
expect(deepEqual(42, 43)).toBe(false);
|
|
13
|
-
expect(deepEqual(
|
|
13
|
+
expect(deepEqual("hello", "world")).toBe(false);
|
|
14
14
|
expect(deepEqual(true, false)).toBe(false);
|
|
15
15
|
expect(deepEqual(null, undefined)).toBe(false);
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
test(
|
|
18
|
+
test("returns same value check for signed zeros and special numbers", () => {
|
|
19
19
|
expect(deepEqual(Math.NaN, Math.NaN)).toBe(true);
|
|
20
20
|
expect(deepEqual(-0, 0)).toBe(false);
|
|
21
21
|
expect(deepEqual(-0, +0)).toBe(false);
|
|
22
|
-
})
|
|
22
|
+
});
|
|
23
23
|
|
|
24
|
-
test(
|
|
24
|
+
test("returns true for deeply equal objects", () => {
|
|
25
25
|
const obj1 = { a: 1, b: { c: 2 } };
|
|
26
26
|
const obj2 = { a: 1, b: { c: 2 } };
|
|
27
27
|
expect(deepEqual(obj1, obj2)).toBe(true);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
test(
|
|
30
|
+
test("returns false for objects with different structures", () => {
|
|
31
31
|
const obj1 = { a: 1, b: { c: 2 } };
|
|
32
32
|
const obj2 = { a: 1, b: { d: 2 } };
|
|
33
33
|
expect(deepEqual(obj1, obj2)).toBe(false);
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
test(
|
|
36
|
+
test("returns false for objects with different values", () => {
|
|
37
37
|
const obj1 = { a: 1, b: { c: 2 } };
|
|
38
38
|
const obj2 = { a: 1, b: { c: 3 } };
|
|
39
39
|
expect(deepEqual(obj1, obj2)).toBe(false);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
test(
|
|
42
|
+
test("returns true for deeply equal arrays", () => {
|
|
43
43
|
const arr1 = [1, 2, { a: 3 }];
|
|
44
44
|
const arr2 = [1, 2, { a: 3 }];
|
|
45
45
|
expect(deepEqual(arr1, arr2)).toBe(true);
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
test(
|
|
48
|
+
test("returns false for arrays with different values", () => {
|
|
49
49
|
const arr1 = [1, 2, { a: 3 }];
|
|
50
50
|
const arr2 = [1, 2, { a: 4 }];
|
|
51
51
|
expect(deepEqual(arr1, arr2)).toBe(false);
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
test(
|
|
54
|
+
test("returns false for objects compared with arrays", () => {
|
|
55
55
|
const obj = { a: 1, b: 2 };
|
|
56
56
|
const arr = [1, 2];
|
|
57
57
|
expect(deepEqual(obj, arr)).toBe(false);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
test(
|
|
60
|
+
test("returns false for different object types", () => {
|
|
61
61
|
const date1 = new Date(2024, 0, 1);
|
|
62
|
-
const date2 = new Date(2024, 0, 1);
|
|
63
62
|
const obj1 = { a: 1, b: 2 };
|
|
64
63
|
expect(deepEqual(date1, obj1)).toBe(false);
|
|
65
64
|
});
|
|
66
65
|
|
|
67
|
-
test(
|
|
66
|
+
test("returns true for nested objects with arrays", () => {
|
|
68
67
|
const obj1 = { a: 1, b: [1, 2, { c: 3 }] };
|
|
69
68
|
const obj2 = { a: 1, b: [1, 2, { c: 3 }] };
|
|
70
69
|
expect(deepEqual(obj1, obj2)).toBe(true);
|
|
71
70
|
});
|
|
72
71
|
|
|
73
|
-
test(
|
|
74
|
-
const obj1 = {
|
|
75
|
-
|
|
72
|
+
test("returns false for functions, as they should not be equal", () => {
|
|
73
|
+
const obj1 = {
|
|
74
|
+
a: 1,
|
|
75
|
+
b: function () {
|
|
76
|
+
return 2;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const obj2 = {
|
|
80
|
+
a: 1,
|
|
81
|
+
b: function () {
|
|
82
|
+
return 2;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
76
85
|
expect(deepEqual(obj1, obj2)).toBe(false);
|
|
77
86
|
});
|
|
78
|
-
});
|
|
87
|
+
});
|