-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] Linking.openURL supports 'target' value
Close #2277
- Loading branch information
1 parent
f736125
commit fa45a22
Showing
3 changed files
with
48 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
37 changes: 37 additions & 0 deletions
37
packages/react-native-web/src/exports/Linking/__tests__/index-test.js
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,37 @@ | ||
/* eslint-env jasmine, jest */ | ||
|
||
import Linking from '..'; | ||
|
||
describe('apis/Linking', () => { | ||
describe('openURL', () => { | ||
test('calls open with a url and target', done => { | ||
jest.spyOn(window, 'open').mockImplementationOnce((url, target, opener) => { | ||
expect(url).toBe('http://foo.com/'); | ||
expect(target).toBe('target_name'); | ||
expect(opener).toBe('noopener'); | ||
done(); | ||
}); | ||
Linking.openURL('http://foo.com', 'target_name'); | ||
}); | ||
|
||
test('defaults target to _blank if not provided', done => { | ||
jest.spyOn(window, 'open').mockImplementationOnce((url, target, opener) => { | ||
expect(url).toBe('http://foo.com/'); | ||
expect(target).toBe('_blank'); | ||
expect(opener).toBe('noopener'); | ||
done(); | ||
}); | ||
Linking.openURL('http://foo.com'); | ||
}); | ||
|
||
test('accepts undefined as a target', done => { | ||
jest.spyOn(window, 'open').mockImplementationOnce((url, target, opener) => { | ||
expect(url).toBe('http://foo.com/'); | ||
expect(target).toBe(undefined); | ||
expect(opener).toBe('noopener'); | ||
done(); | ||
}); | ||
Linking.openURL('http://foo.com', undefined); | ||
}); | ||
}); | ||
}); |
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