|
1 | 1 | import * as TKUnit from "../TKUnit"; |
2 | 2 | import { Label } from "tns-core-modules/ui/label"; |
3 | | - |
4 | 3 | // >> observable-array-require |
5 | 4 | import { ObservableArray, ChangedData, ChangeType } from "tns-core-modules/data/observable-array"; |
6 | 5 | // << observable-array-require |
@@ -115,7 +114,7 @@ export const test_ObservableArray_popShouldRemoveTheLastElement = function () { |
115 | 114 | // >> (hide) |
116 | 115 | const viewBase = new Label(); |
117 | 116 | viewBase.set("testProperty", 0); |
118 | | - viewBase.bind({ sourceProperty: "length", targetProperty: "testProperty" }, array); |
| 117 | + viewBase.bind({sourceProperty: "length", targetProperty: "testProperty"}, array); |
119 | 118 | // << (hide) |
120 | 119 | const result = array.pop(); |
121 | 120 | // << observable-array-join-pop |
@@ -158,7 +157,7 @@ export const test_ObservableArray_pushShouldAppendNewElement = function () { |
158 | 157 | // >> (hide) |
159 | 158 | const viewBase = new Label(); |
160 | 159 | viewBase.set("testProperty", 0); |
161 | | - viewBase.bind({ sourceProperty: "length", targetProperty: "testProperty" }, array); |
| 160 | + viewBase.bind({sourceProperty: "length", targetProperty: "testProperty"}, array); |
162 | 161 | // << (hide) |
163 | 162 | const result = array.push(4); |
164 | 163 | // << observable-array-push |
@@ -197,7 +196,7 @@ export const test_ObservableArray_pushShouldAppendNewElements = function () { |
197 | 196 | // >> (hide) |
198 | 197 | const viewBase = new Label(); |
199 | 198 | viewBase.set("testProperty", 0); |
200 | | - viewBase.bind({ sourceProperty: "length", targetProperty: "testProperty" }, array); |
| 199 | + viewBase.bind({sourceProperty: "length", targetProperty: "testProperty"}, array); |
201 | 200 | // << (hide) |
202 | 201 | const result = array.push(4, 5, 6); |
203 | 202 | // << observable-array-push-multiple |
@@ -236,7 +235,7 @@ export const test_ObservableArray_pushShouldAppendNewElementsFromSourceArray = f |
236 | 235 | // >> (hide) |
237 | 236 | const viewBase = new Label(); |
238 | 237 | viewBase.set("testProperty", 0); |
239 | | - viewBase.bind({ sourceProperty: "length", targetProperty: "testProperty" }, array); |
| 238 | + viewBase.bind({sourceProperty: "length", targetProperty: "testProperty"}, array); |
240 | 239 | // << (hide) |
241 | 240 | const result = array.push([4, 5, 6]); |
242 | 241 | // << observable-array-push-source |
@@ -283,7 +282,7 @@ export const test_ObservableArray_shiftShouldRemoveTheFirstElement = function () |
283 | 282 | // >> (hide) |
284 | 283 | const viewBase = new Label(); |
285 | 284 | viewBase.set("testProperty", 0); |
286 | | - viewBase.bind({ sourceProperty: "length", targetProperty: "testProperty" }, array); |
| 285 | + viewBase.bind({sourceProperty: "length", targetProperty: "testProperty"}, array); |
287 | 286 | // << (hide) |
288 | 287 | const result = array.shift(); |
289 | 288 | // << observable-array-shift |
@@ -355,7 +354,7 @@ export const test_ObservableArray_spliceShouldRemoveSpecifiedNumberOfElementsSta |
355 | 354 | // >> (hide) |
356 | 355 | const viewBase = new Label(); |
357 | 356 | viewBase.set("testProperty", 0); |
358 | | - viewBase.bind({ sourceProperty: "length", targetProperty: "testProperty" }, array); |
| 357 | + viewBase.bind({sourceProperty: "length", targetProperty: "testProperty"}, array); |
359 | 358 | // << (hide) |
360 | 359 | const result = array.splice(1, 2); |
361 | 360 | // << observable-array-splice |
@@ -431,7 +430,7 @@ export const test_ObservableArray_unshiftShouldInsertNewElementsFromTheStart = f |
431 | 430 | // >> (hide) |
432 | 431 | const viewBase = new Label(); |
433 | 432 | viewBase.set("testProperty", 0); |
434 | | - viewBase.bind({ sourceProperty: "length", targetProperty: "testProperty" }, array); |
| 433 | + viewBase.bind({sourceProperty: "length", targetProperty: "testProperty"}, array); |
435 | 434 | // << (hide) |
436 | 435 | const result = array.unshift(4, 5); |
437 | 436 | // << observable-array-unshift |
@@ -633,6 +632,20 @@ export const test_reduce_isDefined = function () { |
633 | 632 | TKUnit.assert(typeof (array.reduce) === "function", "Method 'reduce()' should be defined!"); |
634 | 633 | }; |
635 | 634 |
|
| 635 | +export const test_reduce_without_initial_value = function () { |
| 636 | + const sa = [1, 2, 3]; |
| 637 | + let array: ObservableArray<number> = new ObservableArray(sa); |
| 638 | + const result = array.reduce((a, b) => a + b); |
| 639 | + TKUnit.assertEqual(result, 6, "ObservableArray reduce function broken when initialValue is missing"); |
| 640 | +}; |
| 641 | + |
| 642 | +export const test_reduce_with_initial_value = function () { |
| 643 | + const sa = [1, 2, 3]; |
| 644 | + let array: ObservableArray<number> = new ObservableArray(sa); |
| 645 | + const result = array.reduce((a, b) => a + b, 5); |
| 646 | + TKUnit.assertEqual(result, 11, "ObservableArray reduce function broken when Initial Value is passed."); |
| 647 | +}; |
| 648 | + |
636 | 649 | export const test_reduceRight_isDefined = function () { |
637 | 650 | TKUnit.assert(typeof (array.reduceRight) === "function", "Method 'reduceRight()' should be defined!"); |
638 | 651 | }; |
0 commit comments