-
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.
- Loading branch information
Showing
4 changed files
with
28 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './waitForSelector' | ||
export * from './panzoom' | ||
export * from './isWeixin' | ||
export * from './waitForSelector' |
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,17 @@ | ||
/** | ||
* @vitest-environment happy-dom | ||
*/ | ||
import { isWeixin } from './isWeixin' | ||
|
||
describe('isWeixin', () => { | ||
afterEach(() => { | ||
vi.resetAllMocks() | ||
}) | ||
it('should return false if ua does not contain MicroMessenger', () => { | ||
expect(isWeixin()).toBe(false) | ||
}) | ||
it('should return true if ua contains MicroMessenger', () => { | ||
vi.spyOn(navigator, 'userAgent', 'get').mockReturnValueOnce('MicroMessenger') | ||
expect(isWeixin()).toBe(true) | ||
}) | ||
}) |
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 @@ | ||
/** | ||
* Check if the current environment is Weixin. (微信) | ||
* @returns A boolean value. | ||
*/ | ||
export function isWeixin() { | ||
const ua = navigator.userAgent.toLowerCase() | ||
return /MicroMessenger/i.test(ua) | ||
} |