Skip to content

Commit

Permalink
Add test for calling non-ReactComponentFactoryProxy componentFactory
Browse files Browse the repository at this point in the history
UIP-2410
  • Loading branch information
greglittlefield-wf committed Jun 21, 2017
1 parent 8490f1e commit 88bce6c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/over_react/component_declaration/component_base_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,36 @@ main() {
});
});

test('invokes a non-ReactComponentFactoryProxy componentFactory function properly when invoked', () {
final ReactElement expectedReturnValue = Dom.div()();
const expectedProps = const {'testProp': 'testValue'};

var calls = [];

ReactElement customFactory([Map props, a = 0, b = 0, c = 0, d = 0]) {
calls.add([props, a, b, c, d]);
return expectedReturnValue;
}

var builder = new TestUiPropsWithCustomComponentFactory()
..componentFactory = customFactory
..['testProp'] = 'testValue';

expect(builder(), expectedReturnValue);
expect(builder(1), expectedReturnValue);
expect(builder(1, 2), expectedReturnValue);
expect(builder(1, 2, 3), expectedReturnValue);
expect(builder(1, 2, 3, 4), expectedReturnValue);

expect(calls, [
[expectedProps, 0, 0, 0, 0],
[expectedProps, 1, 0, 0, 0],
[expectedProps, 1, 2, 0, 0],
[expectedProps, 1, 2, 3, 0],
[expectedProps, 1, 2, 3, 4],
]);
});

group('provides Map functionality:', () {
test('is a Map', () {
expect(new TestComponentProps(), const isInstanceOf<Map>());
Expand Down Expand Up @@ -813,3 +843,11 @@ class TestStateMapViewMixin extends Object with MapViewMixin, StateMapViewMixin

TestStateMapViewMixin(this.state);
}

class TestUiPropsWithCustomComponentFactory extends UiProps {
@override
Function componentFactory;

@override
final Map props = {};
}

0 comments on commit 88bce6c

Please sign in to comment.