-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add onramp message and disable apple pay on desktop (#1785)
Co-authored-by: Alissa Crane <alissa.crane@coinbase.com>
- Loading branch information
1 parent
e579527
commit bfe044d
Showing
6 changed files
with
108 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { afterEach, describe, expect, it } from 'vitest'; | ||
import { isApplePaySupported } from './isApplePaySupported'; | ||
|
||
describe('isApplePaySupported', () => { | ||
const originalUserAgent = navigator.userAgent; | ||
|
||
afterEach(() => { | ||
Object.defineProperty(navigator, 'userAgent', { | ||
value: originalUserAgent, | ||
configurable: true, | ||
}); | ||
}); | ||
|
||
it('should return true for iPhone', () => { | ||
Object.defineProperty(navigator, 'userAgent', { | ||
value: | ||
'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1', | ||
configurable: true, | ||
}); | ||
|
||
expect(isApplePaySupported()).toBe(true); | ||
}); | ||
|
||
it('should return true for Safari on macOS', () => { | ||
Object.defineProperty(navigator, 'userAgent', { | ||
value: | ||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15', | ||
configurable: true, | ||
}); | ||
|
||
expect(isApplePaySupported()).toBe(true); | ||
}); | ||
|
||
it('should return false for Chrome on macOS', () => { | ||
Object.defineProperty(navigator, 'userAgent', { | ||
value: | ||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36', | ||
configurable: true, | ||
}); | ||
|
||
expect(isApplePaySupported()).toBe(false); | ||
}); | ||
|
||
it('should return false for Edge on macOS', () => { | ||
Object.defineProperty(navigator, 'userAgent', { | ||
value: | ||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.67', | ||
configurable: true, | ||
}); | ||
|
||
expect(isApplePaySupported()).toBe(false); | ||
}); | ||
|
||
it('should return false for non-Apple devices', () => { | ||
Object.defineProperty(navigator, 'userAgent', { | ||
value: | ||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36', | ||
configurable: true, | ||
}); | ||
|
||
expect(isApplePaySupported()).toBe(false); | ||
}); | ||
}); |
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,8 @@ | ||
export function isApplePaySupported() { | ||
return ( | ||
/iPhone|iPad|iPod/.test(navigator.userAgent) || | ||
(/Safari/.test(navigator.userAgent) && | ||
!/Chrome/.test(navigator.userAgent) && | ||
!/Edg/.test(navigator.userAgent)) | ||
); | ||
} |