Skip to content

Commit 88bce6c

Browse files
Add test for calling non-ReactComponentFactoryProxy componentFactory
UIP-2410
1 parent 8490f1e commit 88bce6c

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/over_react/component_declaration/component_base_test.dart

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,36 @@ main() {
247247
});
248248
});
249249

250+
test('invokes a non-ReactComponentFactoryProxy componentFactory function properly when invoked', () {
251+
final ReactElement expectedReturnValue = Dom.div()();
252+
const expectedProps = const {'testProp': 'testValue'};
253+
254+
var calls = [];
255+
256+
ReactElement customFactory([Map props, a = 0, b = 0, c = 0, d = 0]) {
257+
calls.add([props, a, b, c, d]);
258+
return expectedReturnValue;
259+
}
260+
261+
var builder = new TestUiPropsWithCustomComponentFactory()
262+
..componentFactory = customFactory
263+
..['testProp'] = 'testValue';
264+
265+
expect(builder(), expectedReturnValue);
266+
expect(builder(1), expectedReturnValue);
267+
expect(builder(1, 2), expectedReturnValue);
268+
expect(builder(1, 2, 3), expectedReturnValue);
269+
expect(builder(1, 2, 3, 4), expectedReturnValue);
270+
271+
expect(calls, [
272+
[expectedProps, 0, 0, 0, 0],
273+
[expectedProps, 1, 0, 0, 0],
274+
[expectedProps, 1, 2, 0, 0],
275+
[expectedProps, 1, 2, 3, 0],
276+
[expectedProps, 1, 2, 3, 4],
277+
]);
278+
});
279+
250280
group('provides Map functionality:', () {
251281
test('is a Map', () {
252282
expect(new TestComponentProps(), const isInstanceOf<Map>());
@@ -813,3 +843,11 @@ class TestStateMapViewMixin extends Object with MapViewMixin, StateMapViewMixin
813843

814844
TestStateMapViewMixin(this.state);
815845
}
846+
847+
class TestUiPropsWithCustomComponentFactory extends UiProps {
848+
@override
849+
Function componentFactory;
850+
851+
@override
852+
final Map props = {};
853+
}

0 commit comments

Comments
 (0)