generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add e2e test for Slider and fix cypress:run not showing correct…
… coverage - refs #254313
- Loading branch information
Showing
3 changed files
with
106 additions
and
0 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
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
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { getFieldURL } from './helpers'; | ||
|
||
describe('getFieldURL', () => { | ||
it('handles a URL type object with type and value', () => { | ||
const data = { | ||
'@type': 'URL', | ||
value: 'value_url', | ||
url: 'url_url', | ||
href: 'href_url', | ||
}; | ||
expect(getFieldURL(data)).toEqual('value_url'); | ||
}); | ||
|
||
it('handles an object with type and url', () => { | ||
const data = { | ||
'@type': 'URL', | ||
url: 'url_url', | ||
href: 'href_url', | ||
}; | ||
expect(getFieldURL(data)).toEqual('url_url'); | ||
}); | ||
|
||
it('handles an object with type and href', () => { | ||
const data = { | ||
'@type': 'URL', | ||
href: 'href_url', | ||
}; | ||
expect(getFieldURL(data)).toEqual('href_url'); | ||
}); | ||
|
||
it('handles an object with type and no value, url and href', () => { | ||
const data = { | ||
'@type': 'URL', | ||
}; | ||
expect(getFieldURL(data)).toEqual({ '@type': 'URL' }); | ||
}); | ||
|
||
it('handles an object without a specific type and url', () => { | ||
const data = { | ||
url: 'url_url', | ||
href: 'href_url', | ||
}; | ||
expect(getFieldURL(data)).toEqual('url_url'); | ||
}); | ||
|
||
it('handles an object without a specific type and href', () => { | ||
const data = { | ||
href: 'href_url', | ||
}; | ||
expect(getFieldURL(data)).toEqual('href_url'); | ||
}); | ||
|
||
it('handles an object without a specific type and no id, url, href', () => { | ||
const data = { | ||
test: 'test_url', | ||
}; | ||
expect(getFieldURL(data)).toEqual({ | ||
test: 'test_url', | ||
}); | ||
}); | ||
|
||
it('handles an array', () => { | ||
const data = [ | ||
{ | ||
'@type': 'URL', | ||
value: 'value_url', | ||
url: 'url_url', | ||
href: 'href_url', | ||
}, | ||
{ | ||
'@id': 'id_url', | ||
url: 'url_url', | ||
href: 'href_url', | ||
}, | ||
]; | ||
expect(getFieldURL(data)).toEqual(['value_url', 'id_url']); | ||
}); | ||
|
||
it('handles a string', () => { | ||
const data = '/some/url'; | ||
expect(getFieldURL(data)).toEqual('/some/url'); | ||
}); | ||
|
||
it('returns the data unchanged for non-object/non-array/non-string inputs', () => { | ||
expect(getFieldURL(42)).toEqual(42); | ||
expect(getFieldURL(undefined)).toEqual(undefined); | ||
expect(getFieldURL(null)).toEqual(null); | ||
}); | ||
}); |