caseparser 1.1.0 → 2.0.0-beta2

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.
@@ -1,365 +0,0 @@
1
- 'use strict';
2
-
3
- const caseparser = require('./lib/caseparser');
4
-
5
- const camelToSnake = {
6
- string: function () {
7
- const data = 'firstNameIsBeforeLastName';
8
- const expected = 'first_name_is_before_last_name';
9
- const result = caseparser.camelToSnake(data);
10
- const isFailed = result !== expected;
11
- console.log(' camelToSnake', isFailed ? '✗' : '✓');
12
- if (isFailed) {
13
- console.error(' expected: ', JSON.stringify(expected, null, 2));
14
- console.error(' received: ', JSON.stringify(result, null, 2));
15
- }
16
- },
17
- json: function () {
18
- const data = {
19
- "id": 1,
20
- "isUnderAge": false,
21
- "firstName": "Timothee",
22
- "lastName": "Clausner",
23
- "email": "tclausner0@economist.com",
24
- "telephoneNumbers": [
25
- "(9999) 99999-9999",
26
- "(8888) 88888-8888"
27
- ],
28
- "addresses": [
29
- {
30
- "country": "United_States",
31
- "state": "Illinois",
32
- "city": "Rockford",
33
- "postalCode": "61105",
34
- "street": {
35
- "streetName": "41 Forest Run Circle",
36
- "streetNumber": "539"
37
- }
38
- }
39
- ]
40
- };
41
- const expected = {
42
- "id": 1,
43
- "is_under_age": false,
44
- "first_name": "Timothee",
45
- "last_name": "Clausner",
46
- "email": "tclausner0@economist.com",
47
- "telephone_numbers": [
48
- "(9999) 99999-9999",
49
- "(8888) 88888-8888"
50
- ],
51
- "addresses": [
52
- {
53
- "country": "United_States",
54
- "state": "Illinois",
55
- "city": "Rockford",
56
- "postal_code": "61105",
57
- "street": {
58
- "street_name": "41 Forest Run Circle",
59
- "street_number": "539"
60
- }
61
- }
62
- ]
63
- };
64
- const result = caseparser.camelToSnake(data);
65
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
66
- console.log(' camelToSnake', isFailed ? '✗' : '✓');
67
- if (isFailed) {
68
- console.error(' expected: ', JSON.stringify(expected, null, 2));
69
- console.error(' received: ', JSON.stringify(result, null, 2));
70
- }
71
- }
72
- };
73
-
74
- const camelToDash = {
75
- string: function () {
76
- const data = 'firstNameIsBeforeLastName';
77
- const expected = 'first-name-is-before-last-name';
78
- const result = caseparser.camelToDash(data);
79
- const isFailed = result !== expected;
80
- console.log(' camelToDash', isFailed ? '✗' : '✓');
81
- if (isFailed) {
82
- console.error(' expected: ', JSON.stringify(expected, null, 2));
83
- console.error(' received: ', JSON.stringify(result, null, 2));
84
- }
85
- },
86
- json: function () {
87
- const data = {
88
- "id": 1,
89
- "isUnderAge": false,
90
- "firstName": "Timothee",
91
- "lastName": "Clausner",
92
- "email": "tclausner0@economist.com",
93
- "telephoneNumbers": [
94
- "(9999) 99999-9999",
95
- "(8888) 88888-8888"
96
- ],
97
- "addresses": [
98
- {
99
- "country": "United_States",
100
- "state": "Illinois",
101
- "city": "Rockford",
102
- "postalCode": "61105",
103
- "street": {
104
- "streetName": "41 Forest Run Circle",
105
- "streetNumber": "539"
106
- }
107
- }
108
- ]
109
- };
110
- const expected = {
111
- "id": 1,
112
- "is-under-age": false,
113
- "first-name": "Timothee",
114
- "last-name": "Clausner",
115
- "email": "tclausner0@economist.com",
116
- "telephone-numbers": [
117
- "(9999) 99999-9999",
118
- "(8888) 88888-8888"
119
- ],
120
- "addresses": [
121
- {
122
- "country": "United_States",
123
- "state": "Illinois",
124
- "city": "Rockford",
125
- "postal-code": "61105",
126
- "street": {
127
- "street-name": "41 Forest Run Circle",
128
- "street-number": "539"
129
- }
130
- }
131
- ]
132
- };
133
- const result = caseparser.camelToDash(data);
134
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
135
- console.log(' camelToDash', isFailed ? '✗' : '✓');
136
- if (isFailed) {
137
- console.error(' expected: ', JSON.stringify(expected, null, 2));
138
- console.error(' received: ', JSON.stringify(result, null, 2));
139
- }
140
- }
141
- };
142
-
143
- const camelToPascal = {
144
- string: function () {
145
- const data = 'firstNameIsBeforeLastName';
146
- const expected = 'FirstNameIsBeforeLastName';
147
- const result = caseparser.camelToPascal(data);
148
- const isFailed = result !== expected;
149
- console.log(' camelToPascal', isFailed ? '✗' : '✓');
150
- if (isFailed) {
151
- console.error(' expected: ', JSON.stringify(expected, null, 2));
152
- console.error(' received: ', JSON.stringify(result, null, 2));
153
- }
154
- },
155
- json: function () {
156
- const data = {
157
- "id": 1,
158
- "isUnderAge": false,
159
- "firstName": "Timothee",
160
- "lastName": "Clausner",
161
- "email": "tclausner0@economist.com",
162
- "telephoneNumbers": [
163
- "(9999) 99999-9999",
164
- "(8888) 88888-8888"
165
- ],
166
- "addresses": [
167
- {
168
- "country": "United_States",
169
- "state": "Illinois",
170
- "city": "Rockford",
171
- "postalCode": "61105",
172
- "street": {
173
- "streetName": "41 Forest Run Circle",
174
- "streetNumber": "539"
175
- }
176
- }
177
- ]
178
- };
179
- const expected = {
180
- "Id": 1,
181
- "IsUnderAge": false,
182
- "FirstName": "Timothee",
183
- "LastName": "Clausner",
184
- "Email": "tclausner0@economist.com",
185
- "TelephoneNumbers": [
186
- "(9999) 99999-9999",
187
- "(8888) 88888-8888"
188
- ],
189
- "Addresses": [
190
- {
191
- "Country": "United_States",
192
- "State": "Illinois",
193
- "City": "Rockford",
194
- "PostalCode": "61105",
195
- "Street": {
196
- "StreetName": "41 Forest Run Circle",
197
- "StreetNumber": "539"
198
- }
199
- }
200
- ]
201
- };
202
- const result = caseparser.camelToPascal(data);
203
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
204
- console.log(' camelToPascal', isFailed ? '✗' : '✓');
205
- if (isFailed) {
206
- console.error(' expected: ', JSON.stringify(expected, null, 2));
207
- console.error(' received: ', JSON.stringify(result, null, 2));
208
- }
209
- }
210
- };
211
-
212
- const camelToUpperSnake = {
213
- string: function () {
214
- const data = 'firstNameIsBeforeLastName';
215
- const expected = 'FIRST_NAME_IS_BEFORE_LAST_NAME';
216
- const result = caseparser.camelToUpperSnake(data);
217
- const isFailed = result !== expected;
218
- console.log(' camelToUpperSnake', isFailed ? '✗' : '✓');
219
- if (isFailed) {
220
- console.error(' expected: ', JSON.stringify(expected, null, 2));
221
- console.error(' received: ', JSON.stringify(result, null, 2));
222
- }
223
- },
224
- json: function () {
225
- const data = {
226
- "id": 1,
227
- "isUnderAge": false,
228
- "firstName": "Timothee",
229
- "lastName": "Clausner",
230
- "email": "tclausner0@economist.com",
231
- "telephoneNumbers": [
232
- "(9999) 99999-9999",
233
- "(8888) 88888-8888"
234
- ],
235
- "addresses": [
236
- {
237
- "country": "United_States",
238
- "state": "Illinois",
239
- "city": "Rockford",
240
- "postalCode": "61105",
241
- "street": {
242
- "streetName": "41 Forest Run Circle",
243
- "streetNumber": "539"
244
- }
245
- }
246
- ]
247
- };
248
- const expected = {
249
- "ID": 1,
250
- "IS_UNDER_AGE": false,
251
- "FIRST_NAME": "Timothee",
252
- "LAST_NAME": "Clausner",
253
- "EMAIL": "tclausner0@economist.com",
254
- "TELEPHONE_NUMBERS": [
255
- "(9999) 99999-9999",
256
- "(8888) 88888-8888"
257
- ],
258
- "ADDRESSES": [
259
- {
260
- "COUNTRY": "United_States",
261
- "STATE": "Illinois",
262
- "CITY": "Rockford",
263
- "POSTAL_CODE": "61105",
264
- "STREET": {
265
- "STREET_NAME": "41 Forest Run Circle",
266
- "STREET_NUMBER": "539"
267
- }
268
- }
269
- ]
270
- };
271
- const result = caseparser.camelToUpperSnake(data);
272
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
273
- console.log(' camelToUpperSnake', isFailed ? '✗' : '✓');
274
- if (isFailed) {
275
- console.error(' expected: ', JSON.stringify(expected, null, 2));
276
- console.error(' received: ', JSON.stringify(result, null, 2));
277
- }
278
- }
279
- };
280
-
281
- const camelToUpperDash = {
282
- string: function () {
283
- const data = 'firstNameIsBeforeLastName';
284
- const expected = 'FIRST-NAME-IS-BEFORE-LAST-NAME';
285
- const result = caseparser.camelToUpperDash(data);
286
- const isFailed = result !== expected;
287
- console.log(' camelToUpperDash', isFailed ? '✗' : '✓');
288
- if (isFailed) {
289
- console.error(' expected: ', JSON.stringify(expected, null, 2));
290
- console.error(' received: ', JSON.stringify(result, null, 2));
291
- }
292
- },
293
- json: function () {
294
- const data = {
295
- "id": 1,
296
- "isUnderAge": false,
297
- "firstName": "Timothee",
298
- "lastName": "Clausner",
299
- "email": "tclausner0@economist.com",
300
- "telephoneNumbers": [
301
- "(9999) 99999-9999",
302
- "(8888) 88888-8888"
303
- ],
304
- "addresses": [
305
- {
306
- "country": "United_States",
307
- "state": "Illinois",
308
- "city": "Rockford",
309
- "postalCode": "61105",
310
- "street": {
311
- "streetName": "41 Forest Run Circle",
312
- "streetNumber": "539"
313
- }
314
- }
315
- ]
316
- };
317
- const expected = {
318
- "ID": 1,
319
- "IS-UNDER-AGE": false,
320
- "FIRST-NAME": "Timothee",
321
- "LAST-NAME": "Clausner",
322
- "EMAIL": "tclausner0@economist.com",
323
- "TELEPHONE-NUMBERS": [
324
- "(9999) 99999-9999",
325
- "(8888) 88888-8888"
326
- ],
327
- "ADDRESSES": [
328
- {
329
- "COUNTRY": "United_States",
330
- "STATE": "Illinois",
331
- "CITY": "Rockford",
332
- "POSTAL-CODE": "61105",
333
- "STREET": {
334
- "STREET-NAME": "41 Forest Run Circle",
335
- "STREET-NUMBER": "539"
336
- }
337
- }
338
- ]
339
- };
340
- const result = caseparser.camelToUpperDash(data);
341
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
342
- console.log(' camelToUpperDash', isFailed ? '✗' : '✓');
343
- if (isFailed) {
344
- console.error(' expected: ', JSON.stringify(expected, null, 2));
345
- console.error(' received: ', JSON.stringify(result, null, 2));
346
- }
347
- }
348
- };
349
-
350
- const testCamelCaseSuite = function () {
351
- console.log(' String');
352
- camelToSnake.string();
353
- camelToDash.string();
354
- camelToPascal.string();
355
- camelToUpperSnake.string();
356
- camelToUpperDash.string();
357
- console.log(' JSON');
358
- camelToSnake.json();
359
- camelToDash.json();
360
- camelToPascal.json();
361
- camelToUpperSnake.json();
362
- camelToUpperDash.json();
363
- };
364
-
365
- module.exports = { testCamelCaseSuite };