forked from react-native-community/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add deeplinks to our documentation
These changes will only start to work once our documentation is updated to support this feature: - facebook/react-native-website#3618 - facebook/react-native-website#3619 - facebook/react-native-website#3620
- Loading branch information
Showing
19 changed files
with
258 additions
and
13 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
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
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
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,56 @@ | ||
import * as link from '../doclink'; | ||
|
||
const mockPlatform = jest.fn().mockReturnValue('darwin'); | ||
jest.mock('os', () => ({ | ||
platform: mockPlatform, | ||
})); | ||
|
||
describe('link', () => { | ||
it('builds a link with the platform and os defined', () => { | ||
mockPlatform.mockReturnValueOnce('darwin'); | ||
link.setPlatform('android'); | ||
|
||
const url = new URL(link.docs('environment-setup')).toString(); | ||
expect(url).toMatch(/os=macos/); | ||
expect(url).toMatch(/platform=android/); | ||
expect(url).toEqual( | ||
expect.stringContaining('https://reactnative.dev/docs/environment-setup'), | ||
); | ||
|
||
// Handles a change of os | ||
mockPlatform.mockReturnValueOnce('win32'); | ||
expect(link.docs('environment-setup')).toMatch(/os=windows/); | ||
|
||
// Handles a change of platform | ||
link.setPlatform('ios'); | ||
expect(link.docs('environment-setup')).toMatch(/platform=ios/); | ||
}); | ||
|
||
it('preserves anchor-links', () => { | ||
expect(link.docs('environment-setup', 'ruby')).toMatch(/#ruby/); | ||
}); | ||
|
||
describe('overrides', () => { | ||
afterAll(() => link.setVersion(null)); | ||
it.each([ | ||
[{hash: 'ruby'}, /#ruby/], | ||
[{hash: 'ruby', os: 'linux'}, /os=linux/], | ||
[{platform: 'ios'}, /platform=ios/], | ||
[{'extra stuff': 'here?ok'}, /extra\+stuff=here%3Fok/], | ||
])("link.doc('environment-setup, %o) -> %o", (param, re) => { | ||
expect(link.docs('environment-setup', param)).toMatch(re); | ||
}); | ||
}); | ||
|
||
describe('versions', () => { | ||
afterAll(() => link.setVersion(null)); | ||
it('supports linking to a specific version of React Native', () => { | ||
link.setVersion('0.71'); | ||
expect(link.docs('environment-setup', 'ruby')).toEqual( | ||
expect.stringContaining( | ||
'https://reactnative.dev/docs/0.71/environment-setup', | ||
), | ||
); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.