From a24957fb1216e53dfe7c53513026b9c6dbe64332 Mon Sep 17 00:00:00 2001 From: jameswilddev Date: Fri, 18 Mar 2022 15:41:58 +0000 Subject: [PATCH] Add test and lint. --- .../components/createButtonComponent/unit.tsx | 139 ++++++++++++++++++ react-native/types/ButtonStyle/index.tsx | 14 +- 2 files changed, 152 insertions(+), 1 deletion(-) diff --git a/react-native/components/createButtonComponent/unit.tsx b/react-native/components/createButtonComponent/unit.tsx index 9090811f..9b6c14b4 100644 --- a/react-native/components/createButtonComponent/unit.tsx +++ b/react-native/components/createButtonComponent/unit.tsx @@ -3884,3 +3884,142 @@ test(`renders with a right icon when the left icon is undefined`, () => { ); expect(onPress).not.toHaveBeenCalled(); }); + +test(`renders with a font weight`, () => { + const Component = createButtonComponent({ + fontFamily: `Example Font Family`, + fontWeight: `700`, + fontSize: 16, + horizontalPadding: 10, + verticalPadding: 2, + iconSpacing: 7, + default: { + backgroundColor: `yellow`, + color: `blue`, + radius: 25, + border: { + width: 5, + color: `aquamarine`, + }, + }, + disabled: { + backgroundColor: `orange`, + color: `purple`, + radius: 7, + border: { + width: 2, + color: `aquamarine`, + }, + }, + }); + const onPress = jest.fn(); + + const rendered = ( + null} + rightIcon={() => null} + onPress={onPress} + disabled={false} + > + Example Content + + ); + + expect(unwrapRenderedFunctionComponent(rendered)).toEqual( + + + Example Content + + + ); + expect(onPress).not.toHaveBeenCalled(); +}); + +test(`renders with a font weight of undefined`, () => { + const Component = createButtonComponent({ + fontFamily: `Example Font Family`, + fontWeight: undefined, + fontSize: 16, + horizontalPadding: 10, + verticalPadding: 2, + iconSpacing: 7, + default: { + backgroundColor: `yellow`, + color: `blue`, + radius: 25, + border: { + width: 5, + color: `aquamarine`, + }, + }, + disabled: { + backgroundColor: `orange`, + color: `purple`, + radius: 7, + border: { + width: 2, + color: `aquamarine`, + }, + }, + }); + const onPress = jest.fn(); + + const rendered = ( + null} + rightIcon={() => null} + onPress={onPress} + disabled={false} + > + Example Content + + ); + + expect(unwrapRenderedFunctionComponent(rendered)).toEqual( + + + Example Content + + + ); + expect(onPress).not.toHaveBeenCalled(); +}); diff --git a/react-native/types/ButtonStyle/index.tsx b/react-native/types/ButtonStyle/index.tsx index 38d658ac..2b19302f 100644 --- a/react-native/types/ButtonStyle/index.tsx +++ b/react-native/types/ButtonStyle/index.tsx @@ -17,7 +17,19 @@ export type ButtonStyle = { /** * The weight of the text on the button. */ - readonly fontWeight?: "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900" | undefined; + readonly fontWeight?: + | `normal` + | `bold` + | `100` + | `200` + | `300` + | `400` + | `500` + | `600` + | `700` + | `800` + | `900` + | undefined; /** * The amount of horizontal padding inside the button.