Skip to content

Commit

Permalink
test(@toss/utils): add isMobileWeb test code. (toss#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
po4tion authored Mar 25, 2024
1 parent 5713059 commit ae00613
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/common/utils/src/device/isMobileWeb.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as osCheckModule from './getOSByUserAgent';
import { isMobileWeb } from './isMobileWeb';

describe('isMobileWeb', () => {
it('should return true for iOS user agents', () => {
jest.spyOn(osCheckModule, 'getOSByUserAgent').mockReturnValue('ios');

expect(isMobileWeb()).toBe(true);
});

it('should return true for Android user agents', () => {
jest.spyOn(osCheckModule, 'getOSByUserAgent').mockReturnValue('android');

expect(isMobileWeb()).toBe(true);
});

it('should return false for non-mobile user agents', () => {
jest.spyOn(osCheckModule, 'getOSByUserAgent').mockReturnValue('web');

expect(isMobileWeb()).toBe(false);
});
});

0 comments on commit ae00613

Please sign in to comment.