Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
test: adding new test
Browse files Browse the repository at this point in the history
  • Loading branch information
idindrakusuma committed Jan 9, 2022
1 parent 64921a4 commit a5e369c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/__tests__/getDeviceOS.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import getDeviceOS from '../getDeviceOS';

describe('validating src/getDeviceOS', () => {
let windowSpy: any;

beforeEach(() => {
windowSpy = jest.spyOn(window.navigator, 'userAgent', 'get');
});

afterEach(() => {
windowSpy.mockRestore();
});

it('should return `android` if got UA android', () => {
windowSpy.mockReturnValue(
'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Mobile Safari/537.36',
);
expect(getDeviceOS()).toBe('android');
});

it('should return `ios` if got UA ios', () => {
windowSpy.mockReturnValue(
'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1',
);
expect(getDeviceOS()).toBe('ios');
});
});
2 changes: 1 addition & 1 deletion src/__tests__/isDarkmode.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import isDarkmode from '../isDarkmode';

describe('validaing src/isDarkmode', () => {
let windowSpy;
let windowSpy: any;

beforeEach(() => {
windowSpy = jest.spyOn(window, 'window', 'get');
Expand Down

0 comments on commit a5e369c

Please sign in to comment.