Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2270ff3

Browse files
committedFeb 7, 2016
Add test case to reproduce
1 parent 3a27e2f commit 2270ff3

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed
 

‎examples/content/app.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,17 @@ class App extends Component {
3838
<h1>Content Example</h1>
3939

4040
<p>
41-
If you provide a <Origin className="target custom" content="This is a custom content.">custom</Origin> content of tooltip via props,
42-
it will be used instead of a <Origin className="target default">default</Origin> content of Tooltip component.
41+
If you provide a <Origin className="target custom" content="This is a custom content.">custom</Origin> content via Origin component's prop,
42+
it will overwrite a <Origin className="target default">default</Origin> content of Tooltip component.
4343
</p>
4444

4545
<p>
4646
What time is it <Origin className="target" place="right" onHover={this.handleHover} onLeave={this.handleLeave}>now</Origin>?
4747
</p>
4848

4949
<Tooltip>
50-
This is a default content.
50+
This is a default content.<br />
51+
It's a second line.
5152
</Tooltip>
5253
</div>
5354
);

‎tests/feature/content.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('Content Example', () => {
3838

3939
const tooltip = firstComponent(tree, Tooltip.WrappedComponent).refs.tooltip;
4040
assert(getStyleValue(tooltip, 'visibility') === 'visible');
41-
assert(tooltip.innerText === 'This is a default content.\n', 'should be default content');
41+
assert(tooltip.innerText === "This is a default content.\nIt's a second line.\n", 'should be default content');
4242
});
4343
});
4444

@@ -52,6 +52,25 @@ describe('Content Example', () => {
5252
assert(getStyleValue(tooltip, 'visibility') === 'visible');
5353
assert(tooltip.innerText === 'This is a custom content.\n', 'should be custom content');
5454
});
55+
56+
it('should be resized', () => {
57+
// Mouseover on custom
58+
const custom = firstComponent(tree, Origin.WrappedComponent, { className: 'target custom' }).refs.wrapper;
59+
TestUtils.Simulate.mouseEnter(custom);
60+
61+
const tooltip = firstComponent(tree, Tooltip.WrappedComponent).refs.tooltip;
62+
const customPos = position(tooltip);
63+
TestUtils.Simulate.mouseLeave(custom);
64+
65+
// Mouseover on default
66+
const origin = firstComponent(tree, Origin.WrappedComponent, { className: 'target default' }).refs.wrapper;
67+
TestUtils.Simulate.mouseEnter(origin);
68+
69+
const defaultPos = position(tooltip);
70+
TestUtils.Simulate.mouseLeave(origin);
71+
72+
assert(customPos.height < defaultPos.height, "default's height is higher than custom's height");
73+
});
5574
});
5675

5776
describe('continuous updating content', () => {

0 commit comments

Comments
 (0)
Please sign in to comment.