-
-
Notifications
You must be signed in to change notification settings - Fork 125
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 #62 from JamesBrill/ssr-support
Fix SSR support
- Loading branch information
Showing
4 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export default () => /(android)/i.test(typeof navigator !== 'undefined' ? navigator.userAgent : "") | ||
export default () => /(android)/i.test(typeof navigator !== 'undefined' ? navigator.userAgent : '') |
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,32 @@ | ||
import isAndroid from './isAndroid' | ||
|
||
const mockUserAgent = (userAgent) => { | ||
Object.defineProperty(navigator, 'userAgent', { value: userAgent, writable: true }) | ||
} | ||
|
||
const mockUndefinedNavigator = () => { | ||
Object.defineProperty(global, 'navigator', { value: undefined, writable: true }) | ||
} | ||
|
||
describe('isAndroid', () => { | ||
test('returns false when navigator.userAgent does not contain android string', () => { | ||
mockUserAgent('safari browser') | ||
const result = isAndroid() | ||
|
||
expect(result).toEqual(false) | ||
}) | ||
|
||
test('returns true when navigator.userAgent contains android string', () => { | ||
mockUserAgent('android browser') | ||
const result = isAndroid() | ||
|
||
expect(result).toEqual(true) | ||
}) | ||
|
||
test('returns false when navigator is undefined', () => { | ||
mockUndefinedNavigator() | ||
const result = isAndroid() | ||
|
||
expect(result).toEqual(false) | ||
}) | ||
}) |