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 upperDashToCamel = {
6
- string: function () {
7
- const data = 'FIRST-NAME-IS-BEFORE-LAST-NAME';
8
- const expected = 'firstNameIsBeforeLastName';
9
- const result = caseparser.upperDashToCamel(data);
10
- const isFailed = result !== expected;
11
- console.log(' upperDashToCamel', 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
- "IS-UNDER-AGE": false,
21
- "FIRST-NAME": "Timothee",
22
- "LAST-NAME": "Clausner",
23
- "EMAIL": "tclausner0@economist.com",
24
- "TELEPHONE-NUMBERS": [
25
- "(9999) 99999-9999",
26
- "(8888) 88888-8888"
27
- ],
28
- "ADDRESSES": [
29
- {
30
- "COUNTRY": "United_States",
31
- "STATE": "Illinois",
32
- "CITY": "Rockford",
33
- "POSTAL-CODE": "61105",
34
- "STREET": {
35
- "STREET-NAME": "41 Forest Run Circle",
36
- "STREET-NUMBER": "539"
37
- }
38
- }
39
- ]
40
- };
41
- const expected = {
42
- "id": 1,
43
- "isUnderAge": false,
44
- "firstName": "Timothee",
45
- "lastName": "Clausner",
46
- "email": "tclausner0@economist.com",
47
- "telephoneNumbers": [
48
- "(9999) 99999-9999",
49
- "(8888) 88888-8888"
50
- ],
51
- "addresses": [
52
- {
53
- "country": "United_States",
54
- "state": "Illinois",
55
- "city": "Rockford",
56
- "postalCode": "61105",
57
- "street": {
58
- "streetName": "41 Forest Run Circle",
59
- "streetNumber": "539"
60
- }
61
- }
62
- ]
63
- };
64
- const result = caseparser.upperDashToCamel(data);
65
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
66
- console.log(' upperDashToCamel', 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 upperDashToSnake = {
75
- string: function () {
76
- const data = 'FIRST-NAME-IS-BEFORE-LAST-NAME';
77
- const expected = 'first_name_is_before_last_name';
78
- const result = caseparser.upperDashToSnake(data);
79
- const isFailed = result !== expected;
80
- console.log(' upperDashToSnake', isFailed ? '✗' : '✓');
81
- if (isFailed) {
82
- console.error('expected:data ', expected);
83
- console.error(' received: ', JSON.stringify(result, null, 2));
84
- }
85
- },
86
- json: function () {
87
- const data = {
88
- "ID": 1,
89
- "IS-UNDER-AGE": false,
90
- "FIRST-NAME": "Timothee",
91
- "LAST-NAME": "Clausner",
92
- "EMAIL": "tclausner0@economist.com",
93
- "TELEPHONE-NUMBERS": [
94
- "(9999) 99999-9999",
95
- "(8888) 88888-8888"
96
- ],
97
- "ADDRESSES": [
98
- {
99
- "COUNTRY": "United_States",
100
- "STATE": "Illinois",
101
- "CITY": "Rockford",
102
- "POSTAL-CODE": "61105",
103
- "STREET": {
104
- "STREET-NAME": "41 Forest Run Circle",
105
- "STREET-NUMBER": "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.upperDashToSnake(data);
134
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
135
- console.log(' upperDashToSnake', 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 upperDashToDash = {
144
- string: function () {
145
- const data = 'FIRST-NAME-IS-BEFORE-LAST-NAME';
146
- const expected = 'first-name-is-before-last-name';
147
- const result = caseparser.upperDashToDash(data);
148
- const isFailed = result !== expected;
149
- console.log(' upperDashToDash', 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
- "IS-UNDER-AGE": false,
159
- "FIRST-NAME": "Timothee",
160
- "LAST-NAME": "Clausner",
161
- "EMAIL": "tclausner0@economist.com",
162
- "TELEPHONE-NUMBERS": [
163
- "(9999) 99999-9999",
164
- "(8888) 88888-8888"
165
- ],
166
- "ADDRESSES": [
167
- {
168
- "COUNTRY": "United_States",
169
- "STATE": "Illinois",
170
- "CITY": "Rockford",
171
- "POSTAL-CODE": "61105",
172
- "STREET": {
173
- "STREET-NAME": "41 Forest Run Circle",
174
- "STREET-NUMBER": "539"
175
- }
176
- }
177
- ]
178
- };
179
- const expected = {
180
- "id": 1,
181
- "is-under-age": false,
182
- "first-name": "Timothee",
183
- "last-name": "Clausner",
184
- "email": "tclausner0@economist.com",
185
- "telephone-numbers": [
186
- "(9999) 99999-9999",
187
- "(8888) 88888-8888"
188
- ],
189
- "addresses": [
190
- {
191
- "country": "United_States",
192
- "state": "Illinois",
193
- "city": "Rockford",
194
- "postal-code": "61105",
195
- "street": {
196
- "street-name": "41 Forest Run Circle",
197
- "street-number": "539"
198
- }
199
- }
200
- ]
201
- };
202
- const result = caseparser.upperDashToDash(data);
203
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
204
- console.log(' upperDashToDash', 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 upperDashToPascal = {
213
- string: function () {
214
- const data = 'FIRST-NAME-IS-BEFORE-LAST-NAME';
215
- const expected = 'FirstNameIsBeforeLastName';
216
- const result = caseparser.upperDashToPascal(data);
217
- const isFailed = result !== expected;
218
- console.log(' upperDashToPascal', 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
- "IS-UNDER-AGE": false,
228
- "FIRST-NAME": "Timothee",
229
- "LAST-NAME": "Clausner",
230
- "EMAIL": "tclausner0@economist.com",
231
- "TELEPHONE-NUMBERS": [
232
- "(9999) 99999-9999",
233
- "(8888) 88888-8888"
234
- ],
235
- "ADDRESSES": [
236
- {
237
- "COUNTRY": "United_States",
238
- "STATE": "Illinois",
239
- "CITY": "Rockford",
240
- "POSTAL-CODE": "61105",
241
- "STREET": {
242
- "STREET-NAME": "41 Forest Run Circle",
243
- "STREET-NUMBER": "539"
244
- }
245
- }
246
- ]
247
- };
248
- const expected = {
249
- "Id": 1,
250
- "IsUnderAge": false,
251
- "FirstName": "Timothee",
252
- "LastName": "Clausner",
253
- "Email": "tclausner0@economist.com",
254
- "TelephoneNumbers": [
255
- "(9999) 99999-9999",
256
- "(8888) 88888-8888"
257
- ],
258
- "Addresses": [
259
- {
260
- "Country": "United_States",
261
- "State": "Illinois",
262
- "City": "Rockford",
263
- "PostalCode": "61105",
264
- "Street": {
265
- "StreetName": "41 Forest Run Circle",
266
- "StreetNumber": "539"
267
- }
268
- }
269
- ]
270
- };
271
- const result = caseparser.upperDashToPascal(data);
272
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
273
- console.log(' upperDashToPascal', 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 upperDashToUpperSnake = {
282
- string: function () {
283
- const data = 'FIRST-NAME-IS-BEFORE-LAST-NAME';
284
- const expected = 'FIRST_NAME_IS_BEFORE_LAST_NAME';
285
- const result = caseparser.upperDashToUpperSnake(data);
286
- const isFailed = result !== expected;
287
- console.log(' upperDashToUpperSnake', 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
- "IS-UNDER-AGE": false,
297
- "FIRST-NAME": "Timothee",
298
- "LAST-NAME": "Clausner",
299
- "EMAIL": "tclausner0@economist.com",
300
- "TELEPHONE-NUMBERS": [
301
- "(9999) 99999-9999",
302
- "(8888) 88888-8888"
303
- ],
304
- "ADDRESSES": [
305
- {
306
- "COUNTRY": "United_States",
307
- "STATE": "Illinois",
308
- "CITY": "Rockford",
309
- "POSTAL-CODE": "61105",
310
- "STREET": {
311
- "STREET-NAME": "41 Forest Run Circle",
312
- "STREET-NUMBER": "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.upperDashToUpperSnake(data);
341
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
342
- console.log(' upperDashToUpperSnake', 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 testUpperDashCaseSuite = function () {
351
- console.log(' String:');
352
- upperDashToCamel.string();
353
- upperDashToSnake.string();
354
- upperDashToDash.string();
355
- upperDashToPascal.string();
356
- upperDashToUpperSnake.string();
357
- console.log(' JSON:');
358
- upperDashToCamel.json();
359
- upperDashToSnake.json();
360
- upperDashToDash.json();
361
- upperDashToPascal.json();
362
- upperDashToUpperSnake.json();
363
- };
364
-
365
- module.exports = { testUpperDashCaseSuite };