caseparser 1.1.0 → 2.0.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.
@@ -1,365 +0,0 @@
1
- 'use strict';
2
-
3
- const caseparser = require('./lib/caseparser');
4
-
5
- const pascalToCamel = {
6
- string: function () {
7
- const data = 'FirstNameIsBeforeLastName';
8
- const expected = 'firstNameIsBeforeLastName';
9
- const result = caseparser.pascalToCamel(data);
10
- const isFailed = result !== expected;
11
- console.log(' pascalToCamel', 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
- "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.pascalToCamel(data);
65
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
66
- console.log(' pascalToCamel', 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 pascalToSnake = {
75
- string: function () {
76
- const data = 'FirstNameIsBeforeLastName';
77
- const expected = 'first_name_is_before_last_name';
78
- const result = caseparser.pascalToSnake(data);
79
- const isFailed = result !== expected;
80
- console.log(' pascalToSnake', 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.pascalToSnake(data);
134
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
135
- console.log(' pascalToSnake', 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 pascalToDash = {
144
- string: function () {
145
- const data = 'FirstNameIsBeforeLastName';
146
- const expected = 'first-name-is-before-last-name';
147
- const result = caseparser.pascalToDash(data);
148
- const isFailed = result !== expected;
149
- console.log(' pascalToDash', 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
- "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.pascalToDash(data);
203
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
204
- console.log(' pascalToDash', 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 pascalToUpperSnake = {
213
- string: function () {
214
- const data = 'FirstNameIsBeforeLastName';
215
- const expected = 'FIRST_NAME_IS_BEFORE_LAST_NAME';
216
- const result = caseparser.pascalToUpperSnake(data);
217
- const isFailed = result !== expected;
218
- console.log(' pascalToUpperSnake', 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.pascalToUpperSnake(data);
272
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
273
- console.log(' pascalToUpperSnake', 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 pascalToUpperDash = {
282
- string: function () {
283
- const data = 'FirstNameIsBeforeLastName';
284
- const expected = 'FIRST-NAME-IS-BEFORE-LAST-NAME';
285
- const result = caseparser.pascalToUpperDash(data);
286
- const isFailed = result !== expected;
287
- console.log(' pascalToUpperDash', 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.pascalToUpperDash(data);
341
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
342
- console.log(' pascalToUpperDash', 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 testPascalCaseSuite = function () {
351
- console.log(' String:');
352
- pascalToCamel.string();
353
- pascalToSnake.string();
354
- pascalToDash.string();
355
- pascalToUpperSnake.string();
356
- pascalToUpperDash.string();
357
- console.log(' JSON:');
358
- pascalToCamel.json();
359
- pascalToSnake.json();
360
- pascalToDash.json();
361
- pascalToUpperSnake.json();
362
- pascalToUpperDash.json();
363
- };
364
-
365
- module.exports = { testPascalCaseSuite };