-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathindex.js
35 lines (29 loc) · 865 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Internal dependencies
*/
import warning from '..';
import { logged } from '../utils';
const initialNodeEnv = process.env.NODE_ENV;
describe( 'warning', () => {
afterEach( () => {
process.env.NODE_ENV = initialNodeEnv;
logged.clear();
} );
it( 'logs to console.warn when NODE_ENV is not "production"', () => {
process.env.NODE_ENV = 'development';
warning( 'warning' );
expect( console ).toHaveWarnedWith( 'warning' );
} );
it( 'does not log to console.warn if NODE_ENV is "production"', () => {
process.env.NODE_ENV = 'production';
warning( 'warning' );
expect( console ).not.toHaveWarned();
} );
it( 'should show a message once', () => {
warning( 'warning' );
warning( 'warning' );
expect( console ).toHaveWarned();
// eslint-disable-next-line no-console
expect( console.warn ).toHaveBeenCalledTimes( 1 );
} );
} );