All files / extensions/cornerstone-dicom-rt/src loadRTStruct.test.js

0% Statements 0/15
100% Branches 0/0
0% Functions 0/6
0% Lines 0/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                                                                                                                           
import dcmjs from 'dcmjs';
import loadRTStruct from './loadRTStruct';
 
const { naturalizeDataset } = dcmjs.data.DicomMetaDictionary;
 
// An RTSTRUCT with one ROI and one contour, as dcmjs naturalizes DICOMweb JSON.
// A one-item sequence is then the item object, not an array.
function oneRoiRTStruct() {
  return naturalizeDataset({
    '00080016': { vr: 'UI', Value: ['1.2.840.10008.5.1.4.1.1.481.3'] },
    '0020000E': { vr: 'UI', Value: ['1.2.3.4'] },
    '30060002': { vr: 'SH', Value: ['Structures'] },
    '30060020': {
      vr: 'SQ',
      Value: [{ '30060022': { vr: 'IS', Value: [1] }, '30060026': { vr: 'LO', Value: ['GTV'] } }],
    },
    '30060039': {
      vr: 'SQ',
      Value: [
        {
          '30060084': { vr: 'IS', Value: [1] },
          '30060040': {
            vr: 'SQ',
            Value: [
              {
                '30060042': { vr: 'CS', Value: ['CLOSED_PLANAR'] },
                '30060046': { vr: 'IS', Value: [2] },
                '30060050': { vr: 'DS', Value: [0, 0, 0, 1, 1, 0] },
              },
            ],
          },
        },
      ],
    },
  });
}
 
function makeExtensionManager() {
  const dataSource = {
    getConfig: () => ({ bulkDataURI: { enabled: true } }),
    retrieve: { bulkDataURI: jest.fn() },
  };
  return { getActiveDataSource: () => [dataSource] };
}
 
describe('loadRTStruct', () => {
  it('loads an RTSTRUCT that has one ROI and one contour', async () => {
    const rtStructDisplaySet = { instance: oneRoiRTStruct() };
 
    const structureSet = await loadRTStruct(makeExtensionManager(), rtStructDisplaySet, {});
 
    expect(structureSet.ROIContours).toHaveLength(1);
    const [roi] = structureSet.ROIContours;
    expect(roi.ROIName).toBe('GTV');
    expect(roi.contourPoints).toHaveLength(1);
    expect(roi.contourPoints[0].points).toEqual([
      { x: 0, y: 0, z: 0 },
      { x: 1, y: 1, z: 0 },
    ]);
  });
});