|
4 | 4 | camelCaseObject,
|
5 | 5 | snakeCaseObject,
|
6 | 6 | convertKeyNames,
|
| 7 | + moveCheckboxFieldsToEnd, |
| 8 | + capitalizeFirstLetter, |
7 | 9 | } from './utils';
|
8 | 10 |
|
9 | 11 | describe('modifyObjectKeys', () => {
|
@@ -100,4 +102,68 @@ describe('AsyncActionType', () => {
|
100 | 102 | expect(actionType.FAILURE).toBe('HOUSE_CATS__START_THE_RACE__FAILURE');
|
101 | 103 | expect(actionType.RESET).toBe('HOUSE_CATS__START_THE_RACE__RESET');
|
102 | 104 | });
|
| 105 | + |
| 106 | + describe('moveCheckboxFieldsToEnd', () => { |
| 107 | + it('returns 1 when first field is checkbox and second field is not', () => { |
| 108 | + const a = { type: 'checkbox' }; |
| 109 | + const b = { type: 'text' }; |
| 110 | + |
| 111 | + expect(moveCheckboxFieldsToEnd(a, b)).toEqual(1); |
| 112 | + }); |
| 113 | + |
| 114 | + it('returns -1 when first field is not checkbox and second field is', () => { |
| 115 | + const a = { type: 'text' }; |
| 116 | + const b = { type: 'checkbox' }; |
| 117 | + |
| 118 | + expect(moveCheckboxFieldsToEnd(a, b)).toEqual(-1); |
| 119 | + }); |
| 120 | + |
| 121 | + it('returns 0 when both fields are checkboxes', () => { |
| 122 | + const a = { type: 'checkbox' }; |
| 123 | + const b = { type: 'checkbox' }; |
| 124 | + |
| 125 | + expect(moveCheckboxFieldsToEnd(a, b)).toEqual(0); |
| 126 | + }); |
| 127 | + |
| 128 | + it('returns 0 when neither field is a checkbox', () => { |
| 129 | + const a = { type: 'text' }; |
| 130 | + const b = { type: 'text' }; |
| 131 | + |
| 132 | + expect(moveCheckboxFieldsToEnd(a, b)).toEqual(0); |
| 133 | + }); |
| 134 | + }); |
| 135 | + |
| 136 | + describe('capitalizeFirstLetter', () => { |
| 137 | + it('capitalizes the first letter of a string', () => { |
| 138 | + expect(capitalizeFirstLetter('hello')).toBe('Hello'); |
| 139 | + }); |
| 140 | + |
| 141 | + it('returns an empty string when given an empty string', () => { |
| 142 | + expect(capitalizeFirstLetter('')).toBe(''); |
| 143 | + }); |
| 144 | + |
| 145 | + it('handles single character strings', () => { |
| 146 | + expect(capitalizeFirstLetter('a')).toBe('A'); |
| 147 | + }); |
| 148 | + |
| 149 | + it('handles strings with only one word', () => { |
| 150 | + expect(capitalizeFirstLetter('word')).toBe('Word'); |
| 151 | + }); |
| 152 | + |
| 153 | + it('handles strings with multiple words', () => { |
| 154 | + expect(capitalizeFirstLetter('multiple words')).toBe('Multiple words'); |
| 155 | + }); |
| 156 | + |
| 157 | + it('handles non-string inputs by converting them to strings', () => { |
| 158 | + expect(capitalizeFirstLetter(123)).toBe('123'); |
| 159 | + expect(capitalizeFirstLetter(null)).toBe('Null'); |
| 160 | + expect(capitalizeFirstLetter(undefined)).toBe('Undefined'); |
| 161 | + expect(capitalizeFirstLetter(true)).toBe('True'); |
| 162 | + }); |
| 163 | + |
| 164 | + it('handles strings with special characters', () => { |
| 165 | + expect(capitalizeFirstLetter('!hello')).toBe('!hello'); |
| 166 | + expect(capitalizeFirstLetter('@world')).toBe('@world'); |
| 167 | + }); |
| 168 | + }); |
103 | 169 | });
|
0 commit comments