forked from PantelisGeorgiadis/dcmjs-imaging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test-d.ts
114 lines (104 loc) · 3.19 KB
/
index.test-d.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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import { expectType, expectError } from 'tsd';
import { DicomImage, NativePixelDecoder, WindowLevel, Histogram, log, version, constants } from '.';
const { StandardColorPalette, TransferSyntax } = constants;
// log
expectType<void>(log.error('error'));
// version
expectType<string>(version);
// NativePixelDecoder
expectError(NativePixelDecoder.initializeAsync('string'));
expectType<Promise<void>>(
NativePixelDecoder.initializeAsync({
logNativeDecodersMessages: true,
webAssemblyModulePathOrUrl: '',
})
);
expectType<Promise<void>>(NativePixelDecoder.initializeAsync());
// WindowLevel
expectError(new WindowLevel());
expectError(new WindowLevel(1));
expectError(new WindowLevel('1', '2'));
const windowLevel = new WindowLevel(100, 200, 'WW/WL');
expectError(windowLevel.setWindow('1'));
expectError(windowLevel.setLevel('1'));
expectError(windowLevel.setDescription(1));
expectType<number>(windowLevel.getWindow());
expectType<number>(windowLevel.getLevel());
expectType<string | undefined>(windowLevel.getDescription());
expectType<string>(windowLevel.toString());
expectType<WindowLevel[]>(
WindowLevel.fromDicomImageElements(
new DicomImage({}, TransferSyntax.ImplicitVRLittleEndian).getElements()
)
);
// Histogram
expectError(new Histogram());
expectError(new Histogram(123));
expectError(new Histogram('HISTOGRAM', '1', 2));
expectError(new Histogram('HISTOGRAM', '1', '2'));
const histogram = new Histogram('HISTOGRAM', 0, 5);
expectError(histogram.add('1'));
expectError(histogram.clear('1'));
expectType<number | undefined>(histogram.get(0));
expectType<string>(histogram.getIdentifier());
expectType<number>(histogram.getMinimum());
expectType<number>(histogram.getMaximum());
expectType<string>(histogram.toString());
// DicomImage
expectError(new DicomImage(1));
expectError(new DicomImage('image'));
const pixels = Uint8Array.from([0x00, 0x7f, 0x00, 0xff, 0x00, 0xff, 0x00, 0x7f, 0x00]);
const dicomImage = new DicomImage(
{
Rows: 3,
Columns: 3,
BitsStored: 8,
BitsAllocated: 8,
SamplesPerPixel: 1,
PixelRepresentation: 0,
PhotometricInterpretation: 'MONOCHROME2',
PixelData: [pixels],
},
TransferSyntax.ImplicitVRLittleEndian
);
expectError(dicomImage.setTransferSyntaxUid(12345));
expectError(dicomImage.setElement(1, 2));
expectType<string>(dicomImage.getTransferSyntaxUid());
expectType<number>(dicomImage.getWidth());
expectType<number>(dicomImage.getHeight());
expectType<number>(dicomImage.getNumberOfFrames());
expectError(
dicomImage.render({
frame: '1',
windowLevel: 'WW/WL',
renderOverlays: 1,
calculateHistograms: 0,
})
);
expectError(dicomImage.renderIcon({ frame: 1 }));
expectType<{
frame: number;
width: number;
height: number;
pixels: ArrayBuffer;
windowLevel?: WindowLevel;
histograms?: Array<Histogram>;
colorPalette?: number;
}>(
dicomImage.render({
frame: 0,
renderOverlays: true,
calculateHistograms: true,
colorPalette: StandardColorPalette.HotIron,
})
);
expectType<{
frame: number;
width: number;
height: number;
pixels: ArrayBuffer;
windowLevel?: WindowLevel;
histograms?: Array<Histogram>;
colorPalette?: number;
}>(dicomImage.renderIcon());
expectType<string>(dicomImage.toString());