1
1
/// <reference types="sinon" />
2
2
3
3
import * as React from 'react' ;
4
- import { assert , expect } from 'chai' ;
4
+ import { expect } from 'chai' ;
5
5
import { mount , ReactWrapper } from 'enzyme' ;
6
+ import { setIconOptions } from 'office-ui-fabric-react/lib/Styling' ;
6
7
import { Placeholder } from './PlaceholderComponent' ;
7
- import { IPlaceholderProps } from './IPlaceholderComponent' ;
8
8
import styles from './PlaceholderComponent.module.scss' ;
9
9
10
10
declare const sinon ;
@@ -18,19 +18,26 @@ describe('<Placeholder />', () => {
18
18
const dummyLabel = "Dummy label" ;
19
19
const dummyOnConfigure = sinon . spy ( ( evt ) => { /* Nothing to do here */ } ) ;
20
20
21
+ before ( ( ) => {
22
+ // Suppress icon warnings.
23
+ setIconOptions ( {
24
+ disableWarnings : true
25
+ } ) ;
26
+ } )
27
+
21
28
afterEach ( ( ) => {
22
29
placeholder . unmount ( ) ;
23
30
} ) ;
24
31
25
- it ( 'Test placeholder without button ' , ( done ) => {
32
+ it ( 'Test that placeholder renders ' , ( done ) => {
26
33
placeholder = mount ( < Placeholder description = { dummyDescription } iconName = { dummyIcon } iconText = { dummyText } /> ) ;
27
34
done ( ) ;
28
35
} ) ;
29
36
30
37
it ( 'Test placeholder without button' , ( done ) => {
31
38
placeholder = mount ( < Placeholder description = { dummyDescription } iconName = { dummyIcon } iconText = { dummyText } /> ) ;
32
39
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 ) ;
34
41
35
42
expect ( placeholder . find ( `.${ styles . placeholderText } ` ) ) . to . have . length ( 1 ) ;
36
43
expect ( placeholder . find ( `.${ styles . placeholderText } ` ) . text ( ) ) . to . be . equal ( dummyText ) ;
@@ -45,24 +52,22 @@ describe('<Placeholder />', () => {
45
52
it ( 'Test placeholder with custom classname' , ( done ) => {
46
53
placeholder = mount ( < Placeholder description = { dummyDescription } iconName = { dummyIcon } iconText = { dummyText } contentClassName = { dummyClass } /> ) ;
47
54
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 ) ;
52
56
done ( ) ;
53
57
} ) ;
54
58
55
59
it ( 'Test placeholder with null values' , ( done ) => {
56
60
placeholder = mount ( < Placeholder description = { null } iconName = { null } iconText = { null } /> ) ;
57
61
58
- expect ( placeholder . find ( `div .ms-Icon` ) ) . to . have . length ( 0 ) ;
62
+ expect ( placeholder . find ( 'i[data-icon-name="Add"]' ) ) . to . have . length ( 0 ) ;
59
63
60
64
expect ( placeholder . find ( `div .${ styles . placeholderText } ` ) ) . to . have . length ( 1 ) ;
61
65
expect ( placeholder . find ( `div .${ styles . placeholderText } ` ) . text ( ) ) . to . be . equal ( '' ) ;
62
66
63
67
expect ( placeholder . find ( `div .${ styles . placeholderDescriptionText } ` ) ) . to . have . length ( 1 ) ;
64
68
expect ( placeholder . find ( `div .${ styles . placeholderDescriptionText } ` ) . text ( ) ) . to . be . equal ( '' ) ;
65
69
70
+ expect ( placeholder . find ( 'button' ) ) . to . have . length ( 0 ) ;
66
71
done ( ) ;
67
72
} ) ;
68
73
0 commit comments