From 8f018f531463ec9421947e8c66e5c8f883d68137 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 3 Sep 2024 17:22:13 +0200 Subject: [PATCH] test(links): add linkTo helper function Signed-off-by: Max --- src/tests/helpers/links.spec.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/tests/helpers/links.spec.js b/src/tests/helpers/links.spec.js index dac80a9a594..ba2ef37d1df 100644 --- a/src/tests/helpers/links.spec.js +++ b/src/tests/helpers/links.spec.js @@ -12,10 +12,12 @@ global.OC = { global._oc_webroot = '' +const linkTo = href => domHref({ attrs: { href } }) + describe('Preparing href attributes for the DOM', () => { test('leave empty hrefs alone', () => { - expect(domHref({attrs: {href: ''}})).toBe('') + expect(linkTo('')).toBe('') }) test('leave undefined hrefs alone', () => { @@ -23,22 +25,21 @@ describe('Preparing href attributes for the DOM', () => { }) test('full url', () => { - expect(domHref({attrs: {href: 'https://otherdomain.tld'}})) - .toBe('https://otherdomain.tld') + expect(linkTo('https://otherdomain.tld')).toBe('https://otherdomain.tld') }) test('other protocol', () => { - expect(domHref({attrs: {href: 'mailTo:test@mail.example'}})) + expect(linkTo('mailTo:test@mail.example')) .toBe('mailTo:test@mail.example') }) test('relative link with fileid', () => { - expect(domHref({attrs: {href: 'otherfile?fileId=123'}})) + expect(linkTo('otherfile?fileId=123')) .toBe('/apps/files/?dir=/Wiki&openfile=123#relPath=otherfile') }) test('relative path with ../', () => { - expect(domHref({attrs: {href: '../other/otherfile?fileId=123'}})) + expect(linkTo('../other/otherfile?fileId=123')) .toBe('/apps/files/?dir=/other&openfile=123#relPath=../other/otherfile') }) @@ -48,7 +49,7 @@ describe('Preparing href attributes for the DOM', () => { }) test('absolute path', () => { - expect(domHref({attrs: {href: '/otherfile?fileId=123'}})) + expect(linkTo('/otherfile?fileId=123')) .toBe('/apps/files/?dir=/&openfile=123#relPath=/otherfile') })