Skip to content

Commit

Permalink
Address CR feedback
Browse files Browse the repository at this point in the history
UIP-1897
  • Loading branch information
jacehensley-wf committed Feb 16, 2017
1 parent b271ef4 commit f1f97c3
Showing 1 changed file with 110 additions and 29 deletions.
139 changes: 110 additions & 29 deletions test/over_react/util/react_wrappers_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,64 @@ main() {

group('traverses children of Wrapper components', () {
group('and returns props for a', () {
group('composite JS ReactElement', () {
test('', () {
ReactElement instance = OneLevelWrapper()(
testJsComponentFactory({
'jsProp': 'js',
'style': testStyle,
}, testChildren)
);

expect(getProps(instance, traverseWrappers: true), equals({
'jsProp': 'js',
'style': testStyle,
'children': testChildren
}));
});

test('even when there are multiple levels of wrappers', () {
ReactElement instance = TwoLevelWrapper()(
OneLevelWrapper()(
testJsComponentFactory({
'jsProp': 'js',
'style': testStyle,
}, testChildren)
)
);

expect(getProps(instance, traverseWrappers: true), equals({
'jsProp': 'js',
'style': testStyle,
'children': testChildren
}));
});

test('except when the top level component is not a wrapper', () {
ReactElement instance = testJsComponentFactory({
'jsProp': 'js',
'style': testStyle,
}, testChildren);

expect(getProps(instance, traverseWrappers: true), equals({
'jsProp': 'js',
'style': testStyle,
'children': testChildren
}));
});

test('except when traverseWrappers is false', () {
ReactElement instance = OneLevelWrapper()(
testJsComponentFactory({
'jsProp': 'js',
'style': testStyle,
}, testChildren)
);

expect(getProps(instance), equals({'children': anything}));
});
});

group('composite JS ReactComponent', () {
test('', () {
ReactComponent renderedInstance = render(OneLevelWrapper()(
Expand Down Expand Up @@ -648,11 +706,7 @@ main() {
}, testChildren)
));

expect(getProps(renderedInstance), isNot({
'jsProp': 'js',
'style': testStyle,
'children': testChildren
}));
expect(getProps(renderedInstance), equals({'children': anything}));
});
});

Expand Down Expand Up @@ -689,6 +743,19 @@ main() {
}));
});

test('except when the top level component is not a wrapper', () {
ReactElement instance = (Dom.div()
..addProp('domProp', 'dom')
..style = testStyle
)(testChildren);

expect(getProps(instance, traverseWrappers: true), equals({
'domProp': 'dom',
'style': testStyle,
'children': testChildren
}));
});

test('except when traverseWrappers is false', () {
ReactElement instance = OneLevelWrapper()(
(Dom.div()
Expand All @@ -697,11 +764,7 @@ main() {
)(testChildren)
);

expect(getProps(instance), isNot({
'domProp': 'dom',
'style': testStyle,
'children': testChildren
}));
expect(getProps(instance), equals({'children': anything}));
});
});

Expand Down Expand Up @@ -738,6 +801,19 @@ main() {
}));
});

test('except when the top level component is not a wrapper', () {
ReactElement instance = TestComponentFactory({
'dartProp': 'dart',
'style': testStyle,
}, testChildren);

expect(getProps(instance, traverseWrappers: true), equals({
'dartProp': 'dart',
'style': testStyle,
'children': testChildren
}));
});

test('except when traverseWrappers is false', () {
ReactElement instance = OneLevelWrapper()(
TestComponentFactory({
Expand All @@ -746,25 +822,21 @@ main() {
}, testChildren)
);

expect(getProps(instance), isNot({
'dartProp': 'dart',
'style': testStyle,
'children': testChildren
}));
expect(getProps(instance), equals({'children': anything}));
});
});

group('Dart component ReactComponent', () {
test('', () {
ReactComponent renderedInstance = render(OneLevelWrapper()(
TestComponentFactory({
'jsProp': 'js',
'dartProp': 'dart',
'style': testStyle,
}, testChildren)
));

expect(getProps(renderedInstance, traverseWrappers: true), equals({
'jsProp': 'js',
'dartProp': 'dart',
'style': testStyle,
'children': testChildren
}));
Expand All @@ -774,14 +846,14 @@ main() {
ReactComponent renderedInstance = render(TwoLevelWrapper()(
OneLevelWrapper()(
TestComponentFactory({
'jsProp': 'js',
'dartProp': 'dart',
'style': testStyle,
}, testChildren)
)
));

expect(getProps(renderedInstance, traverseWrappers: true), equals({
'jsProp': 'js',
'dartProp': 'dart',
'style': testStyle,
'children': testChildren
}));
Expand All @@ -791,26 +863,39 @@ main() {
var mountNode = new DivElement();
ReactComponent renderedInstance = react_dom.render(OneLevelWrapper()(
TestComponentFactory({
'jsProp': 'js',
'dartProp': 'dart',
'style': testStyle,
}, testChildren)
), mountNode);

expect(getProps(renderedInstance, traverseWrappers: true), equals({
'jsProp': 'js',
'dartProp': 'dart',
'style': testStyle,
'children': testChildren
}));

renderedInstance = react_dom.render(OneLevelWrapper()(
TestComponentFactory({
'jsProp': 'other js',
'dartProp': 'other dart',
'style': testStyle,
}, testChildren)
), mountNode);

expect(getProps(renderedInstance, traverseWrappers: true), equals({
'jsProp': 'other js',
'dartProp': 'other dart',
'style': testStyle,
'children': testChildren
}));
});

test('expect when the top level component is not a wrapper', () {
ReactComponent renderedInstance = render(TestComponentFactory({
'dartProp': 'dart',
'style': testStyle,
}, testChildren));

expect(getProps(renderedInstance, traverseWrappers: true), equals({
'dartProp': 'dart',
'style': testStyle,
'children': testChildren
}));
Expand All @@ -819,16 +904,12 @@ main() {
test('except when traverseWrappers is false', () {
ReactComponent renderedInstance = render(OneLevelWrapper()(
TestComponentFactory({
'jsProp': 'js',
'dartProp': 'dart',
'style': testStyle,
}, testChildren)
));

expect(getProps(renderedInstance), isNot({
'jsProp': 'other js',
'style': testStyle,
'children': testChildren
}));
expect(getProps(renderedInstance), equals({'children': anything}));
});
});
});
Expand Down

0 comments on commit f1f97c3

Please sign in to comment.