-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(links): add linkTo helper function
Signed-off-by: Max <[email protected]>
- Loading branch information
1 parent
45c743e
commit bd85cc1
Showing
1 changed file
with
8 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,33 +12,34 @@ 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', () => { | ||
expect(domHref({attrs: {}})).toBe(undefined) | ||
}) | ||
|
||
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:[email protected]'}})) | ||
expect(linkTo('mailTo:[email protected]')) | ||
.toBe('mailTo:[email protected]') | ||
}) | ||
|
||
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') | ||
}) | ||
|
||
|