Skip to content

Commit 176a034

Browse files
hackermdhackermd
authored andcommitted
Ensure uid property of ROI is not undefined
1 parent 5a77b9c commit 176a034

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/roi.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class ROI {
1616
if (!('uid' in options)) {
1717
this.uid = generateUuid();
1818
} else {
19+
if (!(typeof options.uid === 'string' || options.uid instanceof String)) {
20+
throw new Error('uid of ROI must be a string')
21+
}
1922
this.uid = options.uid;
2023
}
2124
this.scoord3d = options.scoord3d;

test/api.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,15 @@ describe('dicomMicroscopyViewer.api.VLWholeSlideMicroscopyImageViewer', ()=> {
168168
assert.deepEqual(rois[0].scoord3d.coordinates, newPoint.coordinates);
169169
})
170170

171+
it('should throw an error if uid of ROI is undefined', () => {
172+
assert.throws( function() {
173+
const roid = new dicomMicroscopyViewer.roi.ROI({scoord3d : point, uid: undefined, properties})
174+
}, Error )
175+
})
176+
177+
it('should throw an error if uid of ROI is null', () => {
178+
assert.throws( function() {
179+
const roid = new dicomMicroscopyViewer.roi.ROI({scoord3d : point, uid: null, properties})
180+
}, Error )
181+
})
171182
});

0 commit comments

Comments
 (0)