react-native-timer-picker 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +35 -34
  2. package/dist/commonjs/tests/DurationScroll.test.js +94 -0
  3. package/dist/commonjs/tests/DurationScroll.test.js.map +1 -1
  4. package/dist/commonjs/tests/Modal.test.js +79 -2
  5. package/dist/commonjs/tests/Modal.test.js.map +1 -1
  6. package/dist/commonjs/tests/TimerPicker.test.js +115 -0
  7. package/dist/commonjs/tests/TimerPicker.test.js.map +1 -1
  8. package/dist/commonjs/tests/TimerPickerModal.test.js +120 -0
  9. package/dist/commonjs/tests/TimerPickerModal.test.js.map +1 -1
  10. package/dist/commonjs/tests/colorToRgba.test.js +176 -0
  11. package/dist/commonjs/tests/colorToRgba.test.js.map +1 -0
  12. package/dist/commonjs/tests/generateNumbers.test.js +350 -0
  13. package/dist/commonjs/tests/generateNumbers.test.js.map +1 -0
  14. package/dist/commonjs/tests/getAdjustedLimit.test.js +324 -0
  15. package/dist/commonjs/tests/getAdjustedLimit.test.js.map +1 -0
  16. package/dist/commonjs/tests/getDurationAndIndexFromScrollOffset.test.js +424 -0
  17. package/dist/commonjs/tests/getDurationAndIndexFromScrollOffset.test.js.map +1 -0
  18. package/dist/commonjs/tests/getInitialScrollIndex.test.js +396 -0
  19. package/dist/commonjs/tests/getInitialScrollIndex.test.js.map +1 -0
  20. package/dist/commonjs/tests/getSafeInitialValue.test.js +497 -0
  21. package/dist/commonjs/tests/getSafeInitialValue.test.js.map +1 -0
  22. package/dist/commonjs/tests/padNumber.test.js +301 -0
  23. package/dist/commonjs/tests/padNumber.test.js.map +1 -0
  24. package/dist/commonjs/utils/colorToRgba.js +5 -0
  25. package/dist/commonjs/utils/colorToRgba.js.map +1 -1
  26. package/dist/commonjs/utils/getAdjustedLimit.js +3 -3
  27. package/dist/commonjs/utils/getAdjustedLimit.js.map +1 -1
  28. package/dist/module/tests/DurationScroll.test.js +94 -0
  29. package/dist/module/tests/DurationScroll.test.js.map +1 -1
  30. package/dist/module/tests/Modal.test.js +80 -3
  31. package/dist/module/tests/Modal.test.js.map +1 -1
  32. package/dist/module/tests/TimerPicker.test.js +115 -0
  33. package/dist/module/tests/TimerPicker.test.js.map +1 -1
  34. package/dist/module/tests/TimerPickerModal.test.js +121 -1
  35. package/dist/module/tests/TimerPickerModal.test.js.map +1 -1
  36. package/dist/module/tests/colorToRgba.test.js +174 -0
  37. package/dist/module/tests/colorToRgba.test.js.map +1 -0
  38. package/dist/module/tests/generateNumbers.test.js +348 -0
  39. package/dist/module/tests/generateNumbers.test.js.map +1 -0
  40. package/dist/module/tests/getAdjustedLimit.test.js +322 -0
  41. package/dist/module/tests/getAdjustedLimit.test.js.map +1 -0
  42. package/dist/module/tests/getDurationAndIndexFromScrollOffset.test.js +422 -0
  43. package/dist/module/tests/getDurationAndIndexFromScrollOffset.test.js.map +1 -0
  44. package/dist/module/tests/getInitialScrollIndex.test.js +394 -0
  45. package/dist/module/tests/getInitialScrollIndex.test.js.map +1 -0
  46. package/dist/module/tests/getSafeInitialValue.test.js +495 -0
  47. package/dist/module/tests/getSafeInitialValue.test.js.map +1 -0
  48. package/dist/module/tests/padNumber.test.js +299 -0
  49. package/dist/module/tests/padNumber.test.js.map +1 -0
  50. package/dist/module/utils/colorToRgba.js +5 -0
  51. package/dist/module/utils/colorToRgba.js.map +1 -1
  52. package/dist/module/utils/getAdjustedLimit.js +3 -3
  53. package/dist/module/utils/getAdjustedLimit.js.map +1 -1
  54. package/dist/typescript/components/TimerPicker/styles.d.ts +0 -247
  55. package/dist/typescript/components/TimerPickerModal/styles.d.ts +0 -152
  56. package/package.json +3 -4
@@ -8,6 +8,14 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
8
8
  describe("TimerPickerModal", () => {
9
9
  const mockOnConfirm = jest.fn();
10
10
  const mockOnCancel = jest.fn();
11
+ beforeEach(() => {
12
+ jest.useFakeTimers();
13
+ });
14
+ afterEach(() => {
15
+ jest.runOnlyPendingTimers();
16
+ jest.useRealTimers();
17
+ (0, _reactNative.cleanup)();
18
+ });
11
19
  const defaultProps = {
12
20
  visible: true,
13
21
  setIsVisible: jest.fn(),
@@ -69,5 +77,117 @@ describe("TimerPickerModal", () => {
69
77
  _reactNative.fireEvent.press(confirmButton);
70
78
  expect(mockOnConfirm).toHaveBeenCalledWith(expect.objectContaining({}));
71
79
  });
80
+ it("renders but is not visible when visible prop is false", () => {
81
+ const {
82
+ getByTestId
83
+ } = (0, _reactNative.render)(/*#__PURE__*/_react.default.createElement(_TimerPickerModal.default, _extends({}, defaultProps, {
84
+ visible: false
85
+ })));
86
+ const modal = getByTestId("timer-picker-modal");
87
+ expect(modal).toBeDefined();
88
+ // Modal component still renders but with visible={false}
89
+ expect(modal.props.visible).toBe(false);
90
+ });
91
+ it("renders with custom button labels", () => {
92
+ const {
93
+ getByText
94
+ } = (0, _reactNative.render)(/*#__PURE__*/_react.default.createElement(_TimerPickerModal.default, _extends({}, defaultProps, {
95
+ confirmButtonText: "OK",
96
+ cancelButtonText: "Dismiss"
97
+ })));
98
+ expect(getByText("OK")).toBeDefined();
99
+ expect(getByText("Dismiss")).toBeDefined();
100
+ });
101
+ it("renders with custom modal title", () => {
102
+ const {
103
+ getByText
104
+ } = (0, _reactNative.render)(/*#__PURE__*/_react.default.createElement(_TimerPickerModal.default, _extends({}, defaultProps, {
105
+ modalTitle: "Select Time"
106
+ })));
107
+ expect(getByText("Select Time")).toBeDefined();
108
+ });
109
+ it("does not close on overlay press when closeOnOverlayPress is false", () => {
110
+ const setIsVisibleMock = jest.fn();
111
+ const {
112
+ getByTestId
113
+ } = (0, _reactNative.render)(/*#__PURE__*/_react.default.createElement(_TimerPickerModal.default, _extends({}, defaultProps, {
114
+ closeOnOverlayPress: false,
115
+ setIsVisible: setIsVisibleMock
116
+ })));
117
+ const overlay = getByTestId("modal-backdrop");
118
+ _reactNative.fireEvent.press(overlay);
119
+ expect(setIsVisibleMock).not.toHaveBeenCalled();
120
+ });
121
+ it("hides Cancel button when hideCancelButton is true", () => {
122
+ const {
123
+ queryByText
124
+ } = (0, _reactNative.render)(/*#__PURE__*/_react.default.createElement(_TimerPickerModal.default, _extends({}, defaultProps, {
125
+ hideCancelButton: true
126
+ })));
127
+ expect(queryByText("Cancel")).toBeNull();
128
+ });
129
+ it("renders with initial value", () => {
130
+ const {
131
+ getByTestId
132
+ } = (0, _reactNative.render)(/*#__PURE__*/_react.default.createElement(_TimerPickerModal.default, _extends({}, defaultProps, {
133
+ initialValue: {
134
+ hours: 2,
135
+ minutes: 30,
136
+ seconds: 0
137
+ }
138
+ })));
139
+ expect(getByTestId("timer-picker-modal")).toBeDefined();
140
+ });
141
+ it("renders with custom intervals", () => {
142
+ const {
143
+ getByTestId
144
+ } = (0, _reactNative.render)(/*#__PURE__*/_react.default.createElement(_TimerPickerModal.default, _extends({}, defaultProps, {
145
+ hourInterval: 2,
146
+ minuteInterval: 15,
147
+ secondInterval: 5
148
+ })));
149
+ expect(getByTestId("timer-picker-modal")).toBeDefined();
150
+ });
151
+ it("calls both onCancel and setIsVisible when Cancel is pressed", () => {
152
+ const setIsVisibleMock = jest.fn();
153
+ const onCancelMock = jest.fn();
154
+ const {
155
+ getByText
156
+ } = (0, _reactNative.render)(/*#__PURE__*/_react.default.createElement(_TimerPickerModal.default, _extends({}, defaultProps, {
157
+ onCancel: onCancelMock,
158
+ setIsVisible: setIsVisibleMock
159
+ })));
160
+ const cancelButton = getByText("Cancel");
161
+ _reactNative.fireEvent.press(cancelButton);
162
+ expect(onCancelMock).toHaveBeenCalled();
163
+ expect(setIsVisibleMock).toHaveBeenCalledWith(false);
164
+ });
165
+ it("hides specific time units when respective hide props are provided", () => {
166
+ const {
167
+ getByTestId
168
+ } = (0, _reactNative.render)(/*#__PURE__*/_react.default.createElement(_TimerPickerModal.default, _extends({}, defaultProps, {
169
+ hideHours: true,
170
+ hideSeconds: true
171
+ })));
172
+ expect(getByTestId("timer-picker-modal")).toBeDefined();
173
+ // Note: The specific duration scroll test IDs would be in the TimerPicker component
174
+ });
175
+ it("renders without crashing with all optional props", () => {
176
+ const {
177
+ getByTestId
178
+ } = (0, _reactNative.render)(/*#__PURE__*/_react.default.createElement(_TimerPickerModal.default, _extends({}, defaultProps, {
179
+ modalTitle: "Pick Duration",
180
+ confirmButtonText: "Done",
181
+ cancelButtonText: "Close",
182
+ hourLabel: "h",
183
+ minuteLabel: "m",
184
+ secondLabel: "s",
185
+ hideHours: false,
186
+ hideMinutes: false,
187
+ hideSeconds: false,
188
+ hideDays: false
189
+ })));
190
+ expect(getByTestId("timer-picker-modal")).toBeDefined();
191
+ });
72
192
  });
73
193
  //# sourceMappingURL=TimerPickerModal.test.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_TimerPickerModal","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","describe","mockOnConfirm","jest","fn","mockOnCancel","defaultProps","visible","setIsVisible","onConfirm","onCancel","it","getByTestId","render","createElement","component","expect","toBeDefined","getByText","confirmButton","fireEvent","press","toHaveBeenCalled","cancelButton","setIsVisibleMock","toHaveBeenCalledWith","closeOnOverlayPress","overlay","objectContaining"],"sources":["TimerPickerModal.test.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { render, fireEvent } from \"@testing-library/react-native\";\n\nimport TimerPickerModal from \"../components/TimerPickerModal\";\n\ndescribe(\"TimerPickerModal\", () => {\n const mockOnConfirm = jest.fn();\n const mockOnCancel = jest.fn();\n\n const defaultProps = {\n visible: true,\n setIsVisible: jest.fn(),\n onConfirm: mockOnConfirm,\n onCancel: mockOnCancel,\n };\n\n it(\"renders without crashing\", () => {\n const { getByTestId } = render(<TimerPickerModal {...defaultProps} />);\n const component = getByTestId(\"timer-picker-modal\");\n expect(component).toBeDefined();\n });\n\n it(\"calls onConfirm when Confirm button is pressed\", () => {\n const { getByText } = render(<TimerPickerModal {...defaultProps} />);\n const confirmButton = getByText(\"Confirm\");\n fireEvent.press(confirmButton);\n expect(mockOnConfirm).toHaveBeenCalled();\n });\n\n it(\"calls onCancel when Cancel button is pressed\", () => {\n const { getByText } = render(<TimerPickerModal {...defaultProps} />);\n const cancelButton = getByText(\"Cancel\");\n fireEvent.press(cancelButton);\n expect(mockOnCancel).toHaveBeenCalled();\n });\n\n it(\"hides the modal when Cancel button is pressed\", () => {\n const setIsVisibleMock = jest.fn();\n const { getByText } = render(\n <TimerPickerModal\n {...defaultProps}\n setIsVisible={setIsVisibleMock}\n />\n );\n const cancelButton = getByText(\"Cancel\");\n fireEvent.press(cancelButton);\n expect(setIsVisibleMock).toHaveBeenCalledWith(false);\n });\n\n it(\"hides the modal when overlay is pressed\", () => {\n const setIsVisibleMock = jest.fn();\n const { getByTestId } = render(\n <TimerPickerModal\n {...defaultProps}\n closeOnOverlayPress\n setIsVisible={setIsVisibleMock}\n />\n );\n const overlay = getByTestId(\"modal-backdrop\");\n fireEvent.press(overlay);\n expect(setIsVisibleMock).toHaveBeenCalledWith(false);\n });\n\n it(\"calls onConfirm with selected duration when Confirm button is pressed\", () => {\n const { getByText } = render(<TimerPickerModal {...defaultProps} />);\n // Select duration in TimerPicker, assuming its interaction is tested separately\n const confirmButton = getByText(\"Confirm\");\n fireEvent.press(confirmButton);\n expect(mockOnConfirm).toHaveBeenCalledWith(expect.objectContaining({}));\n });\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,iBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA8D,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,SAAA,WAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,MAAA,CAAAC,MAAA,CAAAC,IAAA,eAAAC,C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AAMG,OAAO,GAAGf,WAAW,CAAC,gBAAgB,CAAC;IAC7CQ,sBAAS,CAACC,KAAK,CAACM,OAAO,CAAC;IACxBX,MAAM,CAACQ,gBAAgB,CAAC,CAACC,oBAAoB,CAAC,KAAK,CAAC;EACxD,CAAC,CAAC;EAEFd,EAAE,CAAC,uEAAuE,EAAE,MAAM;IAC9E,MAAM;MAAEO;IAAU,CAAC,GAAG,IAAAL,mBAAM,eAAChC,MAAA,CAAAO,OAAA,CAAA0B,aAAA,CAAC7B,iBAAA,CAAAG,OAAgB,EAAKkB,YAAe,CAAC,CAAC;IACpE;IACA,MAAMa,aAAa,GAAGD,SAAS,CAAC,SAAS,CAAC;IAC1CE,sBAAS,CAACC,KAAK,CAACF,aAAa,CAAC;IAC9BH,MAAM,CAACd,aAAa,CAAC,CAACuB,oBAAoB,CAACT,MAAM,CAACY,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;EAC3E,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_TimerPickerModal","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","describe","mockOnConfirm","jest","fn","mockOnCancel","beforeEach","useFakeTimers","afterEach","runOnlyPendingTimers","useRealTimers","cleanup","defaultProps","visible","setIsVisible","onConfirm","onCancel","it","getByTestId","render","createElement","component","expect","toBeDefined","getByText","confirmButton","fireEvent","press","toHaveBeenCalled","cancelButton","setIsVisibleMock","toHaveBeenCalledWith","closeOnOverlayPress","overlay","objectContaining","modal","props","toBe","confirmButtonText","cancelButtonText","modalTitle","not","queryByText","hideCancelButton","toBeNull","initialValue","hours","minutes","seconds","hourInterval","minuteInterval","secondInterval","onCancelMock","hideHours","hideSeconds","hourLabel","minuteLabel","secondLabel","hideMinutes","hideDays"],"sources":["TimerPickerModal.test.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { render, fireEvent, cleanup } from \"@testing-library/react-native\";\n\nimport TimerPickerModal from \"../components/TimerPickerModal\";\n\ndescribe(\"TimerPickerModal\", () => {\n const mockOnConfirm = jest.fn();\n const mockOnCancel = jest.fn();\n\n beforeEach(() => {\n jest.useFakeTimers();\n });\n\n afterEach(() => {\n jest.runOnlyPendingTimers();\n jest.useRealTimers();\n cleanup();\n });\n\n const defaultProps = {\n visible: true,\n setIsVisible: jest.fn(),\n onConfirm: mockOnConfirm,\n onCancel: mockOnCancel,\n };\n\n it(\"renders without crashing\", () => {\n const { getByTestId } = render(<TimerPickerModal {...defaultProps} />);\n const component = getByTestId(\"timer-picker-modal\");\n expect(component).toBeDefined();\n });\n\n it(\"calls onConfirm when Confirm button is pressed\", () => {\n const { getByText } = render(<TimerPickerModal {...defaultProps} />);\n const confirmButton = getByText(\"Confirm\");\n fireEvent.press(confirmButton);\n expect(mockOnConfirm).toHaveBeenCalled();\n });\n\n it(\"calls onCancel when Cancel button is pressed\", () => {\n const { getByText } = render(<TimerPickerModal {...defaultProps} />);\n const cancelButton = getByText(\"Cancel\");\n fireEvent.press(cancelButton);\n expect(mockOnCancel).toHaveBeenCalled();\n });\n\n it(\"hides the modal when Cancel button is pressed\", () => {\n const setIsVisibleMock = jest.fn();\n const { getByText } = render(\n <TimerPickerModal\n {...defaultProps}\n setIsVisible={setIsVisibleMock}\n />\n );\n const cancelButton = getByText(\"Cancel\");\n fireEvent.press(cancelButton);\n expect(setIsVisibleMock).toHaveBeenCalledWith(false);\n });\n\n it(\"hides the modal when overlay is pressed\", () => {\n const setIsVisibleMock = jest.fn();\n const { getByTestId } = render(\n <TimerPickerModal\n {...defaultProps}\n closeOnOverlayPress\n setIsVisible={setIsVisibleMock}\n />\n );\n const overlay = getByTestId(\"modal-backdrop\");\n fireEvent.press(overlay);\n expect(setIsVisibleMock).toHaveBeenCalledWith(false);\n });\n\n it(\"calls onConfirm with selected duration when Confirm button is pressed\", () => {\n const { getByText } = render(<TimerPickerModal {...defaultProps} />);\n // Select duration in TimerPicker, assuming its interaction is tested separately\n const confirmButton = getByText(\"Confirm\");\n fireEvent.press(confirmButton);\n expect(mockOnConfirm).toHaveBeenCalledWith(expect.objectContaining({}));\n });\n\n it(\"renders but is not visible when visible prop is false\", () => {\n const { getByTestId } = render(\n <TimerPickerModal {...defaultProps} visible={false} />\n );\n const modal = getByTestId(\"timer-picker-modal\");\n expect(modal).toBeDefined();\n // Modal component still renders but with visible={false}\n expect(modal.props.visible).toBe(false);\n });\n\n it(\"renders with custom button labels\", () => {\n const { getByText } = render(\n <TimerPickerModal\n {...defaultProps}\n confirmButtonText=\"OK\"\n cancelButtonText=\"Dismiss\"\n />\n );\n expect(getByText(\"OK\")).toBeDefined();\n expect(getByText(\"Dismiss\")).toBeDefined();\n });\n\n it(\"renders with custom modal title\", () => {\n const { getByText } = render(\n <TimerPickerModal {...defaultProps} modalTitle=\"Select Time\" />\n );\n expect(getByText(\"Select Time\")).toBeDefined();\n });\n\n it(\"does not close on overlay press when closeOnOverlayPress is false\", () => {\n const setIsVisibleMock = jest.fn();\n const { getByTestId } = render(\n <TimerPickerModal\n {...defaultProps}\n closeOnOverlayPress={false}\n setIsVisible={setIsVisibleMock}\n />\n );\n const overlay = getByTestId(\"modal-backdrop\");\n fireEvent.press(overlay);\n expect(setIsVisibleMock).not.toHaveBeenCalled();\n });\n\n it(\"hides Cancel button when hideCancelButton is true\", () => {\n const { queryByText } = render(\n <TimerPickerModal {...defaultProps} hideCancelButton />\n );\n expect(queryByText(\"Cancel\")).toBeNull();\n });\n\n it(\"renders with initial value\", () => {\n const { getByTestId } = render(\n <TimerPickerModal\n {...defaultProps}\n initialValue={{ hours: 2, minutes: 30, seconds: 0 }}\n />\n );\n expect(getByTestId(\"timer-picker-modal\")).toBeDefined();\n });\n\n it(\"renders with custom intervals\", () => {\n const { getByTestId } = render(\n <TimerPickerModal\n {...defaultProps}\n hourInterval={2}\n minuteInterval={15}\n secondInterval={5}\n />\n );\n expect(getByTestId(\"timer-picker-modal\")).toBeDefined();\n });\n\n it(\"calls both onCancel and setIsVisible when Cancel is pressed\", () => {\n const setIsVisibleMock = jest.fn();\n const onCancelMock = jest.fn();\n const { getByText } = render(\n <TimerPickerModal\n {...defaultProps}\n onCancel={onCancelMock}\n setIsVisible={setIsVisibleMock}\n />\n );\n const cancelButton = getByText(\"Cancel\");\n fireEvent.press(cancelButton);\n expect(onCancelMock).toHaveBeenCalled();\n expect(setIsVisibleMock).toHaveBeenCalledWith(false);\n });\n\n it(\"hides specific time units when respective hide props are provided\", () => {\n const { getByTestId } = render(\n <TimerPickerModal {...defaultProps} hideHours hideSeconds />\n );\n expect(getByTestId(\"timer-picker-modal\")).toBeDefined();\n // Note: The specific duration scroll test IDs would be in the TimerPicker component\n });\n\n it(\"renders without crashing with all optional props\", () => {\n const { getByTestId } = render(\n <TimerPickerModal\n {...defaultProps}\n modalTitle=\"Pick Duration\"\n confirmButtonText=\"Done\"\n cancelButtonText=\"Close\"\n hourLabel=\"h\"\n minuteLabel=\"m\"\n secondLabel=\"s\"\n hideHours={false}\n hideMinutes={false}\n hideSeconds={false}\n hideDays={false}\n />\n );\n expect(getByTestId(\"timer-picker-modal\")).toBeDefined();\n });\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,iBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA8D,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,SAAA,WAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,MAAA,CAAAC,MAAA,CAAAC,IAAA,eAAAC,CAAA,aAAAP,CAAA,MAAAA,CAAA,GAAAQ,SAAA,CAAAC,MAAA,EAAAT,CAAA,UAAAU,CAAA,GAAAF,SAAA,CAAAR,CAAA,YAAAW,CAAA,IAAAD,CAAA,OAAAE,cAAA,CAAAC,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,QAAQ,EAAE;IAAM,EACnB,CACL,CAAC;IACDrC,MAAM,CAACJ,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAACK,WAAW,CAAC,CAAC;EAC3D,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+
3
+ var _colorToRgba = require("../utils/colorToRgba");
4
+ describe("colorToRgba", () => {
5
+ describe("named colors", () => {
6
+ it("converts 'transparent' to rgba", () => {
7
+ expect((0, _colorToRgba.colorToRgba)({
8
+ color: "transparent"
9
+ })).toBe("rgba(0, 0, 0, 0)");
10
+ });
11
+ it("converts 'black' to rgba", () => {
12
+ expect((0, _colorToRgba.colorToRgba)({
13
+ color: "black"
14
+ })).toBe("rgba(0, 0, 0, 1)");
15
+ });
16
+ it("converts 'white' to rgba", () => {
17
+ expect((0, _colorToRgba.colorToRgba)({
18
+ color: "white"
19
+ })).toBe("rgba(255, 255, 255, 1)");
20
+ });
21
+ it("converts 'blue' to rgba", () => {
22
+ expect((0, _colorToRgba.colorToRgba)({
23
+ color: "blue"
24
+ })).toBe("rgba(0, 0, 255, 1)");
25
+ });
26
+ it("converts 'green' to rgba", () => {
27
+ expect((0, _colorToRgba.colorToRgba)({
28
+ color: "green"
29
+ })).toBe("rgba(0, 128, 0, 1)");
30
+ });
31
+ it("converts 'gray' to rgba", () => {
32
+ expect((0, _colorToRgba.colorToRgba)({
33
+ color: "gray"
34
+ })).toBe("rgba(128, 128, 128, 1)");
35
+ });
36
+ it("converts 'red' to rgba", () => {
37
+ expect((0, _colorToRgba.colorToRgba)({
38
+ color: "red"
39
+ })).toBe("rgba(255, 0, 0, 1)");
40
+ });
41
+ });
42
+ describe("RGB format", () => {
43
+ it("converts rgb color to rgba with default opacity", () => {
44
+ expect((0, _colorToRgba.colorToRgba)({
45
+ color: "rgb(255, 0, 0)"
46
+ })).toBe("rgba(255, 0, 0, 1)");
47
+ });
48
+ it("converts rgb color to rgba with custom opacity", () => {
49
+ expect((0, _colorToRgba.colorToRgba)({
50
+ color: "rgb(255, 0, 0)",
51
+ opacity: 0.5
52
+ })).toBe("rgba(255, 0, 0, 0.5)");
53
+ });
54
+ it("converts rgb color with spaces", () => {
55
+ expect((0, _colorToRgba.colorToRgba)({
56
+ color: "rgb(128, 64, 32)"
57
+ })).toBe("rgba(128, 64, 32, 1)");
58
+ });
59
+ it("converts rgb color with no spaces", () => {
60
+ expect((0, _colorToRgba.colorToRgba)({
61
+ color: "rgb(128,64,32)"
62
+ })).toBe("rgba(128, 64, 32, 1)");
63
+ });
64
+ it("handles rgb with zero values", () => {
65
+ expect((0, _colorToRgba.colorToRgba)({
66
+ color: "rgb(0, 0, 0)"
67
+ })).toBe("rgba(0, 0, 0, 1)");
68
+ });
69
+ it("handles rgb with max values", () => {
70
+ expect((0, _colorToRgba.colorToRgba)({
71
+ color: "rgb(255, 255, 255)"
72
+ })).toBe("rgba(255, 255, 255, 1)");
73
+ });
74
+ });
75
+ describe("hex format", () => {
76
+ it("converts 6-digit hex color to rgba", () => {
77
+ expect((0, _colorToRgba.colorToRgba)({
78
+ color: "#FF0000"
79
+ })).toBe("rgba(255, 0, 0, 1)");
80
+ });
81
+ it("converts 6-digit hex color with custom opacity", () => {
82
+ expect((0, _colorToRgba.colorToRgba)({
83
+ color: "#FF0000",
84
+ opacity: 0.7
85
+ })).toBe("rgba(255, 0, 0, 0.7)");
86
+ });
87
+ it("converts 3-digit hex color to rgba", () => {
88
+ expect((0, _colorToRgba.colorToRgba)({
89
+ color: "#F00"
90
+ })).toBe("rgba(255, 0, 0, 1)");
91
+ });
92
+ it("converts 3-digit hex color with custom opacity", () => {
93
+ expect((0, _colorToRgba.colorToRgba)({
94
+ color: "#F00",
95
+ opacity: 0.3
96
+ })).toBe("rgba(255, 0, 0, 0.3)");
97
+ });
98
+ it("converts lowercase hex color", () => {
99
+ expect((0, _colorToRgba.colorToRgba)({
100
+ color: "#ff0000"
101
+ })).toBe("rgba(255, 0, 0, 1)");
102
+ });
103
+ it("converts mixed case hex color", () => {
104
+ expect((0, _colorToRgba.colorToRgba)({
105
+ color: "#Ff00Aa"
106
+ })).toBe("rgba(255, 0, 170, 1)");
107
+ });
108
+ it("converts hex black", () => {
109
+ expect((0, _colorToRgba.colorToRgba)({
110
+ color: "#000000"
111
+ })).toBe("rgba(0, 0, 0, 1)");
112
+ });
113
+ it("converts hex white", () => {
114
+ expect((0, _colorToRgba.colorToRgba)({
115
+ color: "#FFFFFF"
116
+ })).toBe("rgba(255, 255, 255, 1)");
117
+ });
118
+ it("converts 3-digit gray hex", () => {
119
+ expect((0, _colorToRgba.colorToRgba)({
120
+ color: "#888"
121
+ })).toBe("rgba(136, 136, 136, 1)");
122
+ });
123
+ });
124
+ describe("opacity handling", () => {
125
+ it("uses opacity 1 when not provided", () => {
126
+ expect((0, _colorToRgba.colorToRgba)({
127
+ color: "#FF0000"
128
+ })).toBe("rgba(255, 0, 0, 1)");
129
+ });
130
+ it("handles opacity 0", () => {
131
+ expect((0, _colorToRgba.colorToRgba)({
132
+ color: "#FF0000",
133
+ opacity: 0
134
+ })).toBe("rgba(255, 0, 0, 0)");
135
+ });
136
+ it("handles opacity 1", () => {
137
+ expect((0, _colorToRgba.colorToRgba)({
138
+ color: "#FF0000",
139
+ opacity: 1
140
+ })).toBe("rgba(255, 0, 0, 1)");
141
+ });
142
+ it("handles decimal opacity", () => {
143
+ expect((0, _colorToRgba.colorToRgba)({
144
+ color: "#FF0000",
145
+ opacity: 0.42
146
+ })).toBe("rgba(255, 0, 0, 0.42)");
147
+ });
148
+ it("ignores opacity for named color 'transparent'", () => {
149
+ expect((0, _colorToRgba.colorToRgba)({
150
+ color: "transparent",
151
+ opacity: 0.5
152
+ })).toBe("rgba(0, 0, 0, 0)");
153
+ });
154
+ });
155
+ describe("edge cases", () => {
156
+ it("returns original color for unknown format", () => {
157
+ const unknownColor = "hsl(120, 100%, 50%)";
158
+ expect((0, _colorToRgba.colorToRgba)({
159
+ color: unknownColor
160
+ })).toBe(unknownColor);
161
+ });
162
+ it("returns original color for invalid named color", () => {
163
+ const invalidColor = "magenta";
164
+ expect((0, _colorToRgba.colorToRgba)({
165
+ color: invalidColor
166
+ })).toBe(invalidColor);
167
+ });
168
+ it("returns original color for malformed hex", () => {
169
+ const malformedHex = "#GG0000";
170
+ expect((0, _colorToRgba.colorToRgba)({
171
+ color: malformedHex
172
+ })).toBe(malformedHex);
173
+ });
174
+ });
175
+ });
176
+ //# sourceMappingURL=colorToRgba.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_colorToRgba","require","describe","it","expect","colorToRgba","color","toBe","opacity","unknownColor","invalidColor","malformedHex"],"sources":["colorToRgba.test.ts"],"sourcesContent":["import { colorToRgba } from \"../utils/colorToRgba\";\n\ndescribe(\"colorToRgba\", () => {\n describe(\"named colors\", () => {\n it(\"converts 'transparent' to rgba\", () => {\n expect(colorToRgba({ color: \"transparent\" })).toBe(\"rgba(0, 0, 0, 0)\");\n });\n\n it(\"converts 'black' to rgba\", () => {\n expect(colorToRgba({ color: \"black\" })).toBe(\"rgba(0, 0, 0, 1)\");\n });\n\n it(\"converts 'white' to rgba\", () => {\n expect(colorToRgba({ color: \"white\" })).toBe(\"rgba(255, 255, 255, 1)\");\n });\n\n it(\"converts 'blue' to rgba\", () => {\n expect(colorToRgba({ color: \"blue\" })).toBe(\"rgba(0, 0, 255, 1)\");\n });\n\n it(\"converts 'green' to rgba\", () => {\n expect(colorToRgba({ color: \"green\" })).toBe(\"rgba(0, 128, 0, 1)\");\n });\n\n it(\"converts 'gray' to rgba\", () => {\n expect(colorToRgba({ color: \"gray\" })).toBe(\"rgba(128, 128, 128, 1)\");\n });\n\n it(\"converts 'red' to rgba\", () => {\n expect(colorToRgba({ color: \"red\" })).toBe(\"rgba(255, 0, 0, 1)\");\n });\n });\n\n describe(\"RGB format\", () => {\n it(\"converts rgb color to rgba with default opacity\", () => {\n expect(colorToRgba({ color: \"rgb(255, 0, 0)\" })).toBe(\"rgba(255, 0, 0, 1)\");\n });\n\n it(\"converts rgb color to rgba with custom opacity\", () => {\n expect(colorToRgba({ color: \"rgb(255, 0, 0)\", opacity: 0.5 })).toBe(\n \"rgba(255, 0, 0, 0.5)\"\n );\n });\n\n it(\"converts rgb color with spaces\", () => {\n expect(colorToRgba({ color: \"rgb(128, 64, 32)\" })).toBe(\"rgba(128, 64, 32, 1)\");\n });\n\n it(\"converts rgb color with no spaces\", () => {\n expect(colorToRgba({ color: \"rgb(128,64,32)\" })).toBe(\"rgba(128, 64, 32, 1)\");\n });\n\n it(\"handles rgb with zero values\", () => {\n expect(colorToRgba({ color: \"rgb(0, 0, 0)\" })).toBe(\"rgba(0, 0, 0, 1)\");\n });\n\n it(\"handles rgb with max values\", () => {\n expect(colorToRgba({ color: \"rgb(255, 255, 255)\" })).toBe(\"rgba(255, 255, 255, 1)\");\n });\n });\n\n describe(\"hex format\", () => {\n it(\"converts 6-digit hex color to rgba\", () => {\n expect(colorToRgba({ color: \"#FF0000\" })).toBe(\"rgba(255, 0, 0, 1)\");\n });\n\n it(\"converts 6-digit hex color with custom opacity\", () => {\n expect(colorToRgba({ color: \"#FF0000\", opacity: 0.7 })).toBe(\"rgba(255, 0, 0, 0.7)\");\n });\n\n it(\"converts 3-digit hex color to rgba\", () => {\n expect(colorToRgba({ color: \"#F00\" })).toBe(\"rgba(255, 0, 0, 1)\");\n });\n\n it(\"converts 3-digit hex color with custom opacity\", () => {\n expect(colorToRgba({ color: \"#F00\", opacity: 0.3 })).toBe(\"rgba(255, 0, 0, 0.3)\");\n });\n\n it(\"converts lowercase hex color\", () => {\n expect(colorToRgba({ color: \"#ff0000\" })).toBe(\"rgba(255, 0, 0, 1)\");\n });\n\n it(\"converts mixed case hex color\", () => {\n expect(colorToRgba({ color: \"#Ff00Aa\" })).toBe(\"rgba(255, 0, 170, 1)\");\n });\n\n it(\"converts hex black\", () => {\n expect(colorToRgba({ color: \"#000000\" })).toBe(\"rgba(0, 0, 0, 1)\");\n });\n\n it(\"converts hex white\", () => {\n expect(colorToRgba({ color: \"#FFFFFF\" })).toBe(\"rgba(255, 255, 255, 1)\");\n });\n\n it(\"converts 3-digit gray hex\", () => {\n expect(colorToRgba({ color: \"#888\" })).toBe(\"rgba(136, 136, 136, 1)\");\n });\n });\n\n describe(\"opacity handling\", () => {\n it(\"uses opacity 1 when not provided\", () => {\n expect(colorToRgba({ color: \"#FF0000\" })).toBe(\"rgba(255, 0, 0, 1)\");\n });\n\n it(\"handles opacity 0\", () => {\n expect(colorToRgba({ color: \"#FF0000\", opacity: 0 })).toBe(\"rgba(255, 0, 0, 0)\");\n });\n\n it(\"handles opacity 1\", () => {\n expect(colorToRgba({ color: \"#FF0000\", opacity: 1 })).toBe(\"rgba(255, 0, 0, 1)\");\n });\n\n it(\"handles decimal opacity\", () => {\n expect(colorToRgba({ color: \"#FF0000\", opacity: 0.42 })).toBe(\"rgba(255, 0, 0, 0.42)\");\n });\n\n it(\"ignores opacity for named color 'transparent'\", () => {\n expect(colorToRgba({ color: \"transparent\", opacity: 0.5 })).toBe(\"rgba(0, 0, 0, 0)\");\n });\n });\n\n describe(\"edge cases\", () => {\n it(\"returns original color for unknown format\", () => {\n const unknownColor = \"hsl(120, 100%, 50%)\";\n expect(colorToRgba({ color: unknownColor })).toBe(unknownColor);\n });\n\n it(\"returns original color for invalid named color\", () => {\n const invalidColor = \"magenta\";\n expect(colorToRgba({ color: invalidColor })).toBe(invalidColor);\n });\n\n it(\"returns original color for malformed hex\", () => {\n const malformedHex = \"#GG0000\";\n expect(colorToRgba({ color: malformedHex })).toBe(malformedHex);\n });\n });\n});\n"],"mappings":";;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEAC,QAAQ,CAAC,aAAa,EAAE,MAAM;EAC1BA,QAAQ,CAAC,cAAc,EAAE,MAAM;IAC3BC,EAAE,CAAC,gCAAgC,EAAE,MAAM;MACvCC,MAAM,CAAC,IAAAC,wBAAW,EAAC;QAAEC,KAAK,EAAE;MAAc,CAAC,CAAC,CAAC,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