-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from coston/allow-html-href-if-human-interaction
Allow html href if human interaction
- Loading branch information
Showing
6 changed files
with
53 additions
and
31 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -4,14 +4,15 @@ import Obfuscate from '../src/obfuscate.js' | |
const testEmail = '[email protected]' | ||
const testTel = '205-454-1234' | ||
const testTelReveresed = '4321-454-502' | ||
const originalLocation = 'https://example.com/' | ||
|
||
|
||
describe('obfuscate', () => { | ||
beforeEach(() => { | ||
delete global.window.location | ||
|
||
global.window.location = { | ||
href: new URL('https://example.com'), | ||
href: new URL(originalLocation), | ||
} | ||
}) | ||
|
||
|
@@ -152,6 +153,15 @@ describe('obfuscate', () => { | |
expect(wrapper.prop('href')).toEqual(`mailto:${testEmail}`) | ||
}) | ||
|
||
test('Human interaction disables onClick setting js location.href', () => { | ||
const wrapper = shallow( | ||
<Obfuscate facetime={testTel} /> | ||
) | ||
wrapper.simulate('mouseover') | ||
wrapper.simulate('click') | ||
expect(global.window.location.href.toString()).toEqual(originalLocation) | ||
}) | ||
|
||
test('Return empty href link if child is an object and no link is provided', () => { | ||
const wrapper = shallow( | ||
<Obfuscate ><button>This is a child object</button></Obfuscate> | ||
|