Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit f68bbf9

Browse files
committed
added unit tests
1 parent 8d25b54 commit f68bbf9

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

__mocks__/Dimensions.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
jest.mock("react-native/Libraries/Utilities/Dimensions", () => {
2+
const Dimensions = require.requireActual(
3+
"react-native/Libraries/Utilities/Dimensions"
4+
);
5+
Dimensions.get = jest.fn().mockReturnValue({ width: 100, height: 100 });
6+
return Dimensions;
7+
});

__tests__/index.unit.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import {
2+
responsiveHeight,
3+
responsiveWidth,
4+
responsiveFontSize,
5+
responsiveScreenHeight,
6+
responsiveScreenWidth,
7+
responsiveScreenFontSize
8+
} from "../lib/index";
9+
10+
describe("Testing common utils", () => {
11+
it("responsiveHeight", () => {
12+
const height = responsiveHeight(20);
13+
expect(height).toBe(20);
14+
});
15+
16+
it("responsiveWidth", () => {
17+
const width = responsiveWidth(20);
18+
expect(width).toBe(20);
19+
});
20+
21+
it("responsiveFontSize", () => {
22+
const fontSize = responsiveFontSize(2);
23+
expect(fontSize).toBe(4.0794577223746264);
24+
});
25+
26+
it("responsiveScreenHeight", () => {
27+
const height = responsiveScreenHeight(20);
28+
expect(height).toBe(20);
29+
});
30+
31+
it("responsiveScreenWidth", () => {
32+
const width = responsiveScreenWidth(20);
33+
expect(width).toBe(20);
34+
});
35+
36+
it("responsiveScreenFontSize", () => {
37+
const fontSize = responsiveScreenFontSize(2);
38+
expect(fontSize).toBe(4.0794577223746264);
39+
});
40+
});
41+
42+
describe("Testing hooks", () => {});

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = {
22
preset: "@testing-library/react-native",
3+
setupFilesAfterEnv: ["./__mocks__/Dimensions.ts"],
34
verbose: true,
45
transformIgnorePatterns: [
56
"node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base)"

0 commit comments

Comments
 (0)