This repository was archived by the owner on Dec 29, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
Original file line number Diff line number Diff line change 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" , ( ) => { } ) ;
Original file line number Diff line number Diff line change 11module . 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)"
You can’t perform that action at this time.
0 commit comments