+
+ describe('getInlineFileUrl', () => {
+ it('should add the collection\'s uuid to the hostname', () => {
+ // when
+ const webDavUrlA = 'https://*.collections.example.com/';
+ const webDavUrlB = 'https://*--collections.example.com/';
+ const webDavDownloadUrl = 'https://example.com/';
+
+ // then
+ expect(getInlineFileUrl(url, webDavDownloadUrl, webDavUrlA))
+ .toBe('https://zzzzz-4zz18-0123456789abcde.collections.example.com/t=v2/a/b/LIMS/1.html');
+ expect(getInlineFileUrl(url, webDavDownloadUrl, webDavUrlB))
+ .toBe('https://zzzzz-4zz18-0123456789abcde--collections.example.com/t=v2/a/b/LIMS/1.html');
+ expect(getInlineFileUrl(urlWithPdh, webDavDownloadUrl, webDavUrlA))
+ .toBe('https://012345678901234567890123456789aa-0.collections.example.com/t=v2/a/b/LIMS/1.html');
+ expect(getInlineFileUrl(urlWithPdh, webDavDownloadUrl, webDavUrlB))
+ .toBe('https://012345678901234567890123456789aa-0--collections.example.com/t=v2/a/b/LIMS/1.html');
+ });
+
+ it('should keep the url the same when no inline url available', () => {
+ // when
+ const webDavUrl = '';
+ const webDavDownloadUrl = 'https://example.com/';
+ const result = getInlineFileUrl(url, webDavDownloadUrl, webDavUrl);
+
+ // then
+ expect(result).toBe('https://example.com/c=zzzzz-4zz18-0123456789abcde/t=v2/a/b/LIMS/1.html');
+ });
+
+ it('should replace the url when available', () => {
+ // when
+ const webDavUrl = 'https://download.example.com/';
+ const webDavDownloadUrl = 'https://example.com/';
+ const result = getInlineFileUrl(url, webDavDownloadUrl, webDavUrl);
+
+ // then
+ expect(result).toBe('https://download.example.com/c=zzzzz-4zz18-0123456789abcde/t=v2/a/b/LIMS/1.html');
+ });
+ });
+});