@@ -10,6 +10,8 @@ export function shouldError(about) {
10
10
11
11
describe ( 'deprecated' , function ( ) {
12
12
beforeEach ( function ( ) {
13
+ deprecated . _resetWarned ( ) ;
14
+
13
15
// because 'warning' package uses console.error instead of console.warn
14
16
sinon . stub ( console , 'error' ) ;
15
17
} ) ;
@@ -22,16 +24,23 @@ describe('deprecated', function() {
22
24
return deprecated ( React . PropTypes . string , 'Read more at link' ) ( { pName : prop } , 'pName' , 'ComponentName' ) ;
23
25
}
24
26
25
- it ( 'Should warn about deprecation and validate OK' , function ( ) {
27
+ it ( 'should warn about deprecation and validate OK' , function ( ) {
26
28
const err = validate ( 'value' ) ;
27
29
shouldError ( '"pName" property of "ComponentName" has been deprecated.\nRead more at link' ) ;
28
30
assert . notInstanceOf ( err , Error ) ;
29
31
} ) ;
30
32
31
- it ( 'Should warn about deprecation and throw validation error when property value is not OK' , function ( ) {
33
+ it ( 'should warn about deprecation and throw validation error when property value is not OK' , function ( ) {
32
34
const err = validate ( { } ) ;
33
35
shouldError ( '"pName" property of "ComponentName" has been deprecated.\nRead more at link' ) ;
34
36
assert . instanceOf ( err , Error ) ;
35
37
assert . include ( err . message , 'Invalid undefined `pName` of type `object` supplied to `ComponentName`' ) ;
36
38
} ) ;
39
+
40
+ it ( 'should not emit the same warning more than once' , function ( ) {
41
+ validate ( 'value' ) ;
42
+ validate ( 'value' ) ;
43
+ console . error . should . have . been . calledOnce ;
44
+ shouldError ( 'deprecated' ) ;
45
+ } ) ;
37
46
} ) ;
0 commit comments