All files / platform/core/src/utils getWADORSImageId.test.js

0% Statements 0/27
100% Branches 0/0
0% Functions 0/9
0% Lines 0/27

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 63 64 65 66                                                                                                                                   
import getWADORSImageId from './getWADORSImageId';
 
describe('getWADORSImageId', () => {
  it('should always return undefined if the instance has no `wadorsuri` property', () => {
    const frame = '42';
    const instance = {};
 
    expect(getWADORSImageId(instance)).toBeUndefined();
    expect(getWADORSImageId(instance, frame)).toBeUndefined();
  });
 
  it('should always prepend the `wadorsuri` with `wadors:`', () => {
    const frame = '42';
    const instance = {
      wadorsuri: 'wadorsuri',
    };
 
    expect(getWADORSImageId(instance)).toEqual('wadors:wadorsuri');
    expect(getWADORSImageId(instance, frame)).toEqual('wadors:wadorsuri');
  });
 
  describe('with no frame provided', () => {
    it('should replace `frames/:number` with `frames/1`', () => {
      const instance = {
        wadorsuri: 'frames/42',
      };
 
      expect(getWADORSImageId(instance)).toEqual('wadors:frames/1');
    });
 
    it('should work on a real wadorsuri', () => {
      const instance = {
        wadorsuri:
          'https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs/studies/1.3.6.1.4.1.25403.52237031786.3872.20100510032220.1/series/1.3.6.1.4.1.25403.52237031786.3872.20100510032220.2/instances/1.3.6.1.4.1.25403.52237031786.3872.20100510032220.8/frames/22',
      };
 
      expect(getWADORSImageId(instance)).toEqual(
        'wadors:https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs/studies/1.3.6.1.4.1.25403.52237031786.3872.20100510032220.1/series/1.3.6.1.4.1.25403.52237031786.3872.20100510032220.2/instances/1.3.6.1.4.1.25403.52237031786.3872.20100510032220.8/frames/1'
      );
    });
  });
 
  describe('with a frame provided', () => {
    it('should replace `frames/:number` with the argument frame plus one', () => {
      const frame = '42';
      const instance = {
        wadorsuri: 'frames/1',
      };
 
      expect(getWADORSImageId(instance, frame)).toEqual('wadors:frames/43');
    });
 
    it('should work on a real wadorsuri', () => {
      const frame = '42';
      const instance = {
        wadorsuri:
          'https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs/studies/1.3.6.1.4.1.25403.52237031786.3872.20100510032220.1/series/1.3.6.1.4.1.25403.52237031786.3872.20100510032220.2/instances/1.3.6.1.4.1.25403.52237031786.3872.20100510032220.8/frames/22',
      };
 
      expect(getWADORSImageId(instance, frame)).toEqual(
        'wadors:https://server.dcmjs.org/dcm4chee-arc/aets/DCM4CHEE/rs/studies/1.3.6.1.4.1.25403.52237031786.3872.20100510032220.1/series/1.3.6.1.4.1.25403.52237031786.3872.20100510032220.2/instances/1.3.6.1.4.1.25403.52237031786.3872.20100510032220.8/frames/43'
      );
    });
  });
});