Skip to content

Commit

Permalink
Update mock
Browse files Browse the repository at this point in the history
  • Loading branch information
zoontek committed Jan 16, 2024
1 parent 54edfe6 commit a7f6136
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 36 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,11 @@ You can add / remove supported localizations in your Xcode project infos:
## How to test your code

Because it's a native module, you need to mock this package.<br />
The package provides a default mock you may use in your \_\_mocks\_\_/react-native-localize.js or jest.setup.js.
The package provides a default mock you may import in your `__mocks__` directory:

```ts
import localizeMock from "react-native-localize/mock";

jest.mock("react-native-localize", () => localizeMock);
// __mocks__/react-native-localize.ts
export * from "react-native-localize/mock";
```

## Sponsors
Expand Down
14 changes: 7 additions & 7 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ PODS:
- FlipperKit/FlipperKitNetworkPlugin
- fmt (6.2.1)
- glog (0.3.5)
- hermes-engine (0.73.1):
- hermes-engine/Pre-built (= 0.73.1)
- hermes-engine/Pre-built (0.73.1)
- hermes-engine (0.73.2):
- hermes-engine/Pre-built (= 0.73.2)
- hermes-engine/Pre-built (0.73.2)
- libevent (2.1.12)
- OpenSSL-Universal (1.1.1100)
- RCT-Folly (2022.05.16.00):
Expand Down Expand Up @@ -1310,9 +1310,9 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/yoga"

SPEC CHECKSUMS:
boost: 26fad476bfa736552bbfa698a06cc530475c1505
boost: d3f49c53809116a5d38da093a8aa78bf551aed09
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
FBLazyVector: fbc4957d9aa695250b55d879c1d86f79d7e69ab4
FBReactNativeSpec: 86de768f89901ef6ed3207cd686362189d64ac88
Flipper: c7a0093234c4bdd456e363f2f19b2e4b27652d44
Expand All @@ -1324,8 +1324,8 @@ SPEC CHECKSUMS:
Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9
FlipperKit: 37525a5d056ef9b93d1578e04bc3ea1de940094f
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
hermes-engine: 34df9d5034e90bd9bf1505e1ca198760373935af
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
hermes-engine: b361c9ef5ef3cda53f66e195599b47e1f84ffa35
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
RCT-Folly: 7169b2b1c44399c76a47b5deaaba715eeeb476c0
Expand Down
35 changes: 10 additions & 25 deletions mock/index.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,27 @@
export const getCalendar = () => "gregorian"; // the calendar identifier you want
export const getCountry = () => "US"; // the country code you want
export const getCurrencies = () => ["USD", "EUR"]; // can be empty array

export const getLocales = () => [
// extend if needed, add the locales you want
{ countryCode: "US", languageTag: "en-US", languageCode: "en", isRTL: false },
{ countryCode: "FR", languageTag: "fr-FR", languageCode: "fr", isRTL: false },
];

export const getNumberFormatSettings = () => ({
decimalSeparator: ".",
groupingSeparator: ",",
});

// use a provided translation, or return undefined to test your fallback
export const findBestLanguageTag = () => ({
languageTag: "en-US",
isRTL: false,
});

export const getNumberFormatSettings = () => ({
decimalSeparator: ".",
groupingSeparator: ",",
});

export const getCalendar = () => "gregorian"; // the calendar identifier you want
export const getCountry = () => "US"; // the country code you want
export const getCurrencies = () => ["USD", "EUR"]; // can be empty array
export const getTemperatureUnit = () => "celsius"; // or "fahrenheit"
export const getTimeZone = () => "Europe/Paris"; // the timezone you want
export const uses24HourClock = () => true;
export const usesMetricSystem = () => true;
export const usesAutoDateAndTime = () => true;
export const usesAutoTimeZone = () => true;

export default {
getCalendar,
getCountry,
getCurrencies,
getLocales,
getNumberFormatSettings,
getTemperatureUnit,
getTimeZone,
uses24HourClock,
usesMetricSystem,
usesAutoDateAndTime,
usesAutoTimeZone,

findBestLanguageTag,
};
export const usesMetricSystem = () => true;

0 comments on commit a7f6136

Please sign in to comment.