cdk-common 2.0.1396 → 2.0.1398

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.
@@ -69,12 +69,14 @@ test('merge()', function (t) {
69
69
  );
70
70
 
71
71
  t.test('with overflow objects (from arrayLimit)', function (st) {
72
+ // arrayLimit is max index, so with limit 0, max index 0 is allowed (1 element)
73
+ // To create overflow, need 2+ elements with limit 0, or 3+ with limit 1, etc.
72
74
  st.test('merges primitive into overflow object at next index', function (s2t) {
73
- // Create an overflow object via combine
74
- var overflow = utils.combine(['a'], 'b', 1, false);
75
+ // Create an overflow object via combine: 3 elements (indices 0-2) with limit 0
76
+ var overflow = utils.combine(['a', 'b'], 'c', 0, false);
75
77
  s2t.ok(utils.isOverflow(overflow), 'overflow object is marked');
76
- var merged = utils.merge(overflow, 'c');
77
- s2t.deepEqual(merged, { 0: 'a', 1: 'b', 2: 'c' }, 'adds primitive at next numeric index');
78
+ var merged = utils.merge(overflow, 'd');
79
+ s2t.deepEqual(merged, { 0: 'a', 1: 'b', 2: 'c', 3: 'd' }, 'adds primitive at next numeric index');
78
80
  s2t.end();
79
81
  });
80
82
 
@@ -94,21 +96,21 @@ test('merge()', function (t) {
94
96
  });
95
97
 
96
98
  st.test('merges overflow object into primitive', function (s2t) {
97
- // Create an overflow object via combine
98
- var overflow = utils.combine([], 'b', 0, false);
99
+ // Create an overflow object via combine: 2 elements (indices 0-1) with limit 0
100
+ var overflow = utils.combine(['a'], 'b', 0, false);
99
101
  s2t.ok(utils.isOverflow(overflow), 'overflow object is marked');
100
- var merged = utils.merge('a', overflow);
102
+ var merged = utils.merge('c', overflow);
101
103
  s2t.ok(utils.isOverflow(merged), 'result is also marked as overflow');
102
- s2t.deepEqual(merged, { 0: 'a', 1: 'b' }, 'creates object with primitive at 0, source values shifted');
104
+ s2t.deepEqual(merged, { 0: 'c', 1: 'a', 2: 'b' }, 'creates object with primitive at 0, source values shifted');
103
105
  s2t.end();
104
106
  });
105
107
 
106
108
  st.test('merges overflow object with multiple values into primitive', function (s2t) {
107
- // Create an overflow object via combine
108
- var overflow = utils.combine(['b'], 'c', 1, false);
109
+ // Create an overflow object via combine: 3 elements (indices 0-2) with limit 0
110
+ var overflow = utils.combine(['b', 'c'], 'd', 0, false);
109
111
  s2t.ok(utils.isOverflow(overflow), 'overflow object is marked');
110
112
  var merged = utils.merge('a', overflow);
111
- s2t.deepEqual(merged, { 0: 'a', 1: 'b', 2: 'c' }, 'shifts all source indices by 1');
113
+ s2t.deepEqual(merged, { 0: 'a', 1: 'b', 2: 'c', 3: 'd' }, 'shifts all source indices by 1');
112
114
  s2t.end();
113
115
  });
114
116
 
@@ -196,7 +198,7 @@ test('combine()', function (t) {
196
198
 
197
199
  st.test('exactly at the limit stays as array', function (s2t) {
198
200
  var combined = utils.combine(['a', 'b'], 'c', 3, false);
199
- s2t.deepEqual(combined, ['a', 'b', 'c'], 'stays as array when exactly at limit');
201
+ s2t.deepEqual(combined, ['a', 'b', 'c'], 'stays as array when count equals limit');
200
202
  s2t.ok(Array.isArray(combined), 'result is an array');
201
203
  s2t.end();
202
204
  });
@@ -208,16 +210,30 @@ test('combine()', function (t) {
208
210
  s2t.end();
209
211
  });
210
212
 
211
- st.test('with arrayLimit 0', function (s2t) {
213
+ st.test('with arrayLimit 1', function (s2t) {
214
+ var combined = utils.combine([], 'a', 1, false);
215
+ s2t.deepEqual(combined, ['a'], 'stays as array when count equals limit');
216
+ s2t.ok(Array.isArray(combined), 'result is an array');
217
+ s2t.end();
218
+ });
219
+
220
+ st.test('with arrayLimit 0 converts single element to object', function (s2t) {
212
221
  var combined = utils.combine([], 'a', 0, false);
213
- s2t.deepEqual(combined, { 0: 'a' }, 'converts single element to object with arrayLimit 0');
222
+ s2t.deepEqual(combined, { 0: 'a' }, 'converts to object when count exceeds limit');
223
+ s2t.notOk(Array.isArray(combined), 'result is not an array');
224
+ s2t.end();
225
+ });
226
+
227
+ st.test('with arrayLimit 0 and two elements converts to object', function (s2t) {
228
+ var combined = utils.combine(['a'], 'b', 0, false);
229
+ s2t.deepEqual(combined, { 0: 'a', 1: 'b' }, 'converts to object when count exceeds limit');
214
230
  s2t.notOk(Array.isArray(combined), 'result is not an array');
215
231
  s2t.end();
216
232
  });
217
233
 
218
234
  st.test('with plainObjects option', function (s2t) {
219
- var combined = utils.combine(['a'], 'b', 1, true);
220
- var expected = { __proto__: null, 0: 'a', 1: 'b' };
235
+ var combined = utils.combine(['a', 'b'], 'c', 1, true);
236
+ var expected = { __proto__: null, 0: 'a', 1: 'b', 2: 'c' };
221
237
  s2t.deepEqual(combined, expected, 'converts to object with null prototype');
222
238
  s2t.equal(Object.getPrototypeOf(combined), null, 'result has null prototype when plainObjects is true');
223
239
  s2t.end();
@@ -228,13 +244,13 @@ test('combine()', function (t) {
228
244
 
229
245
  t.test('with existing overflow object', function (st) {
230
246
  st.test('adds to existing overflow object at next index', function (s2t) {
231
- // Create overflow object first via combine
232
- var overflow = utils.combine(['a'], 'b', 1, false);
247
+ // Create overflow object first via combine: 3 elements (indices 0-2) with limit 0
248
+ var overflow = utils.combine(['a', 'b'], 'c', 0, false);
233
249
  s2t.ok(utils.isOverflow(overflow), 'initial object is marked as overflow');
234
250
 
235
- var combined = utils.combine(overflow, 'c', 10, false);
251
+ var combined = utils.combine(overflow, 'd', 10, false);
236
252
  s2t.equal(combined, overflow, 'returns the same object (mutated)');
237
- s2t.deepEqual(combined, { 0: 'a', 1: 'b', 2: 'c' }, 'adds value at next numeric index');
253
+ s2t.deepEqual(combined, { 0: 'a', 1: 'b', 2: 'c', 3: 'd' }, 'adds value at next numeric index');
238
254
  s2t.end();
239
255
  });
240
256
 
package/package.json CHANGED
@@ -54,7 +54,7 @@
54
54
  "jsii-docgen": "^10.5.0",
55
55
  "jsii-pacmak": "^1.126.0",
56
56
  "jsii-rosetta": "5.7.x",
57
- "projen": "0.99.11",
57
+ "projen": "0.99.12",
58
58
  "ts-jest": "^27",
59
59
  "typescript": "^5"
60
60
  },
@@ -87,7 +87,7 @@
87
87
  "publishConfig": {
88
88
  "access": "public"
89
89
  },
90
- "version": "2.0.1396",
90
+ "version": "2.0.1398",
91
91
  "jest": {
92
92
  "coverageProvider": "v8",
93
93
  "testMatch": [