UNPKG

@applicaster/zapp-react-native-utils

Version:

Applicaster Zapp React Native utilities package

34 lines (28 loc) 936 B
import * as utils from ".."; import { DEFAULT_NAMESPACE } from "../../consts"; describe("Context Keys Manager Utils - getNamespaceAndKey", () => { it("returns the input if it's not a string", () => { const input = { key: "some_key", namespace: "some_value" }; expect(utils.getNamespaceAndKey(input)).toBe(input); }); it("splits the provided string with the last dot", () => { const namespace = "com.plugin.feature"; const key = "key_name"; const namespacedKey = `${namespace}.${key}`; expect(utils.getNamespaceAndKey(namespacedKey)).toEqual( expect.objectContaining({ namespace, key, }) ); }); it("returns the key name with default namespace if the string has no dot", () => { const key = "key_name"; expect(utils.getNamespaceAndKey(key)).toEqual( expect.objectContaining({ namespace: DEFAULT_NAMESPACE, key, }) ); }); });