UNPKG

@applicaster/zapp-react-native-utils

Version:

Applicaster Zapp React Native utilities package

65 lines (54 loc) 1.85 kB
import * as stylesUtils from "../index"; describe("extractMasterCell", () => { const { extractMasterCell } = stylesUtils; const masterCell = { content_types: { default: { states: { default: { some: 1, properties: "a" } } }, }, }; const cellStyles = { "ABC-1234": masterCell }; const component = { styles: { master_cell_id: "ABC-1234" } }; it("extract a master cell if found a matching master_cell_id", () => { expect(extractMasterCell({ cellStyles, component })).toEqual(masterCell); }); it("returns undefined if no matching master_cell_id was found", () => { expect( extractMasterCell({ cellStyles, component: { styles: { master_cell_id: "SOME-OTHER-ID" } }, }) ).toBeUndefined(); }); it("returns undefined if there is no master_cell_id in the component style", () => { expect( extractMasterCell({ cellStyles, component: { styles: {} } }) ).toBeUndefined(); }); describe("with cell_builder plugin configuration", () => { const cellStylesWithPluginConfiguration = { "ABC-1234": { ...masterCell, plugin_identifier: "MyCellBuilderPluginIdentifier", }, }; it("returns undefined if there is a plugin_identifier", () => { expect( extractMasterCell({ cellStyles: cellStylesWithPluginConfiguration, component, }) ).toBeUndefined(); }); it.skip("Returns a cell plugin configuration when plugin_identifier is present", () => { expect( extractMasterCell({ cellStyles: cellStylesWithPluginConfiguration, component, }) ).not.toBeUndefined(); }); }); it("returns undefined if the cellStyles object is empty", () => { expect(extractMasterCell({ cellStyles: {}, component })).toBeUndefined(); }); });