Skip to content

Commit 876ea4e

Browse files
authored
Merge pull request #399 from dmitryrogozhny/master
Fix for issue #398
2 parents f3947ae + d75a98c commit 876ea4e

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

src/controls/placeholder/PlaceholderComponent.module.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import '~office-ui-fabric-react/dist/sass/References.scss';
2+
13
.placeholder {
24
display: -webkit-box;
35
display: -ms-flexbox;
@@ -26,13 +28,18 @@
2628
display: inline-block;
2729
vertical-align: middle;
2830
white-space: normal;
31+
32+
@include ms-fontSize-su;
2933
}
3034

3135
.placeholderText {
3236
display: inline;
3337
vertical-align: middle;
3438
white-space: normal;
3539

40+
@include ms-fontWeight-light;
41+
@include ms-fontSize-xxl;
42+
3643
&.hide {
3744
display: none;
3845
}

src/controls/placeholder/PlaceholderComponent.test.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/// <reference types="sinon" />
22

33
import * as React from 'react';
4-
import { assert, expect } from 'chai';
4+
import { expect } from 'chai';
55
import { mount, ReactWrapper } from 'enzyme';
6+
import { setIconOptions } from 'office-ui-fabric-react/lib/Styling';
67
import { Placeholder } from './PlaceholderComponent';
7-
import { IPlaceholderProps } from './IPlaceholderComponent';
88
import styles from './PlaceholderComponent.module.scss';
99

1010
declare const sinon;
@@ -18,19 +18,26 @@ describe('<Placeholder />', () => {
1818
const dummyLabel = "Dummy label";
1919
const dummyOnConfigure = sinon.spy((evt) => { /* Nothing to do here */ });
2020

21+
before(() => {
22+
// Suppress icon warnings.
23+
setIconOptions({
24+
disableWarnings: true
25+
});
26+
})
27+
2128
afterEach(() => {
2229
placeholder.unmount();
2330
});
2431

25-
it('Test placeholder without button', (done) => {
32+
it('Test that placeholder renders', (done) => {
2633
placeholder = mount(<Placeholder description={dummyDescription} iconName={dummyIcon} iconText={dummyText} />);
2734
done();
2835
});
2936

3037
it('Test placeholder without button', (done) => {
3138
placeholder = mount(<Placeholder description={dummyDescription} iconName={dummyIcon} iconText={dummyText} />);
3239

33-
expect(placeholder.find('i.ms-Icon--Add')).to.have.length(1);
40+
expect(placeholder.find('i[data-icon-name="Add"]')).to.have.length(1);
3441

3542
expect(placeholder.find(`.${styles.placeholderText}`)).to.have.length(1);
3643
expect(placeholder.find(`.${styles.placeholderText}`).text()).to.be.equal(dummyText);
@@ -45,24 +52,22 @@ describe('<Placeholder />', () => {
4552
it('Test placeholder with custom classname', (done) => {
4653
placeholder = mount(<Placeholder description={dummyDescription} iconName={dummyIcon} iconText={dummyText} contentClassName={dummyClass} />);
4754

48-
expect(placeholder.find(`div.${dummyClass}`)).to.have.length(1);
49-
expect(placeholder.find(`div.${dummyClass} .ms-Icon`)).to.have.length(1);
50-
51-
expect(placeholder.find(`div.${dummyClass} button`)).to.have.length(0);
55+
expect(placeholder.find(`div.${styles.placeholder}.${dummyClass}`)).to.have.length(1);
5256
done();
5357
});
5458

5559
it('Test placeholder with null values', (done) => {
5660
placeholder = mount(<Placeholder description={null} iconName={null} iconText={null} />);
5761

58-
expect(placeholder.find(`div .ms-Icon`)).to.have.length(0);
62+
expect(placeholder.find('i[data-icon-name="Add"]')).to.have.length(0);
5963

6064
expect(placeholder.find(`div .${styles.placeholderText}`)).to.have.length(1);
6165
expect(placeholder.find(`div .${styles.placeholderText}`).text()).to.be.equal('');
6266

6367
expect(placeholder.find(`div .${styles.placeholderDescriptionText}`)).to.have.length(1);
6468
expect(placeholder.find(`div .${styles.placeholderDescriptionText}`).text()).to.be.equal('');
6569

70+
expect(placeholder.find('button')).to.have.length(0);
6671
done();
6772
});
6873

src/controls/placeholder/PlaceholderComponent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ export class Placeholder extends React.Component<IPlaceholderProps, IPlaceholder
9090
<div className={styles.placeholderHead}>
9191
<div className={styles.placeholderHeadContainer}>
9292
{
93-
this.props.iconName && <Icon iconName={this.props.iconName} className={`${styles.placeholderIcon} ms-fontSize-su ms-Icon`} />
93+
this.props.iconName && <Icon iconName={this.props.iconName} className={styles.placeholderIcon} />
9494
}
95-
<span className={`${styles.placeholderText} ms-fontWeight-light ms-fontSize-xxl ${(this.state.width && this.state.width <= 380) ? styles.hide : "" }`}>{this.props.iconText}</span>
95+
<span className={`${styles.placeholderText} ${(this.state.width && this.state.width <= 380) ? styles.hide : "" }`}>{this.props.iconText}</span>
9696
</div>
9797
</div>
9898
<div className={styles.placeholderDescription}>

0 commit comments

Comments
 (0)