Skip to content

Commit 22ada67

Browse files
committed
Add more tests
1 parent a5562cc commit 22ada67

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

components/SLDSTooltip/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ module.exports = React.createClass( {
132132
verticalAlign={this.getVerticalAlign()}
133133
flippable={false}
134134
onClose={this.handleCancel}>
135-
<div className={cx(style)}>
135+
<div className={cx(style)} role="tooltip">
136136
{this.getTooltipContent()}
137137
</div>
138138
</SLDSPopover>:null;

tests/SLDSTooltip/tooltip.test.jsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,34 @@ describe('SLDSTooltip: ', function(){
1717
});
1818

1919
describe('component basic props render', function() {
20+
it('renders tooltip trigger text', function() {
21+
let triggerText = 'Click here for tooltip';
22+
let tooltip = generateTooltip(<SLDSTooltip align='left' content='This is more info. blah blah.' openOn='click'>{triggerText}</SLDSTooltip>);
23+
let tooltipTrigger = tooltip.innerText;
24+
expect(tooltipTrigger).to.equal(triggerText);
25+
});
26+
27+
it('aligns', function() {
28+
let popoverText = 'This is more info. blah blah.';
29+
let tooltip = generateTooltip(<SLDSTooltip align='right' content={popoverText} openOn='click'>Click Me</SLDSTooltip>);
30+
TestUtils.Simulate.click(tooltip);
31+
let reactId = tooltip.getElementsByTagName('noscript')[0].getAttribute("data-reactid");
32+
expect(reactId).to.equal('.x.$right middle');
33+
});
34+
});
35+
36+
describe('functionality works', function() {
37+
it("renders popover onHover with onOpen prop === 'hover'", function() {
38+
let tooltip = generateTooltip(<SLDSTooltip align='right' content={popoverText} openOn='hover'>Click Me</SLDSTooltip>);
39+
TestUtils.Simulate.hover(tooltip);
40+
});
41+
42+
it("renders popover onClick with onOpen prop === 'click'", function() {
43+
let tooltip = generateTooltip(<SLDSTooltip align='right' content={popoverText} openOn='click'>Click Me</SLDSTooltip>);
44+
TestUtils.Simulate.click(tooltip);
45+
});
46+
2047
});
2148

49+
2250
});

0 commit comments

Comments
 (0)