File tree Expand file tree Collapse file tree 9 files changed +97
-50
lines changed Expand file tree Collapse file tree 9 files changed +97
-50
lines changed Original file line number Diff line number Diff line change 22
22
"babel-preset-react" : " ^6.11.1" ,
23
23
"babel-preset-stage-1" : " ^6.13.0" ,
24
24
"babel-preset-stage-2" : " ^6.13.0" ,
25
+ "babel-register" : " ^6.18.0" ,
25
26
"babelify" : " ^7.3.0" ,
26
27
"brfs" : " ^1.4.3" ,
28
+ "chai" : " ^3.5.0" ,
27
29
"enzyme" : " ^2.4.1" ,
28
30
"eslint" : " ^1.6.0" ,
29
31
"eslint-plugin-react" : " ^3.5.1" ,
30
32
"gulp" : " ^3.9.0" ,
31
- "jest" : " ^14.1.0" ,
32
33
"jest-cli" : " ^14.1.0" ,
34
+ "jsdom" : " ^9.8.3" ,
33
35
"lodash" : " ^4.14.2" ,
36
+ "mocha" : " ^3.2.0" ,
34
37
"react" : " ^0.14 || ^15.0.0-rc || ^15.0" ,
35
38
"react-addons-test-utils" : " ^15.3.1" ,
36
39
"react-component-gulp-tasks" : " git+https://github.com/gor181/react-component-gulp-tasks.git" ,
37
40
"react-dom" : " ^0.14 || ^15.0.0-rc || ^15.0" ,
38
41
"react-notification-system" : " ^0.2.7" ,
39
42
"react-redux" : " ^4.4.5" ,
40
- "redux" : " ^3.5.2"
43
+ "redux" : " ^3.5.2" ,
44
+ "sinon" : " ^1.17.6"
41
45
},
42
46
"dependencies" : {
43
47
"react-notification-system" : " ^0.2.7"
56
60
"publish:site" : " NODE_ENV=production gulp publish:examples" ,
57
61
"release" : " NODE_ENV=production gulp release" ,
58
62
"start" : " gulp dev" ,
59
- "test" : " jest" ,
63
+ "test" : " mocha test/__tests__/**/*" ,
64
+ "test-dev" : " mocha test/__tests__/**/* --watch" ,
60
65
"watch" : " gulp watch:lib"
61
66
},
62
67
"keywords" : [
63
- " react" ,
64
- " react-component"
65
- ],
66
- "jest" : {
67
- "automock" : false
68
- }
68
+ " react-notification-system" ,
69
+ " redux"
70
+ ]
69
71
}
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import { expect } from 'chai' ;
2
+ import * as Actions from '../../src/actions' ;
3
+
4
+ describe ( 'actions' , ( ) => {
5
+ it ( 'sets the correct notification level' , ( ) => {
6
+ expect ( Actions . success ( ) . level ) . to . equal ( 'success' ) ;
7
+ expect ( Actions . warning ( ) . level ) . to . equal ( 'warning' ) ;
8
+ expect ( Actions . info ( ) . level ) . to . equal ( 'info' ) ;
9
+ expect ( Actions . error ( ) . level ) . to . equal ( 'error' ) ;
10
+ } ) ;
11
+
12
+ it ( 'accepts custom opts' , ( ) => {
13
+ expect ( Actions . success ( { custom : true } ) . custom ) . to . be . ok ;
14
+ } ) ;
15
+
16
+ it ( 'generates random uid when not provided' , ( ) => {
17
+ expect ( Actions . success ( ) . uid ) . to . be . defined ;
18
+ } ) ;
19
+
20
+ if ( 'sets the custom uid when provided' , ( ) => {
21
+ expect ( Actions . success ( { uid : 1 } ) . uid ) . to . equal ( 1 ) ;
22
+ } ) ;
23
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { expect } from 'chai' ;
2
+ import * as Constants from '../../src/const' ;
3
+
4
+ describe ( 'constants' , ( ) => {
5
+ it ( 'should be defined' , ( ) => {
6
+ expect ( Constants . RNS_SHOW_NOTIFICATION ) . to . be . defined ;
7
+ expect ( Constants . RNS_HIDE_NOTIFICATION ) . to . be . defined ;
8
+ } ) ;
9
+ } ) ;
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import { shallow } from 'enzyme' ;
3
- import Component from '../notifications' ;
3
+ import { expect } from 'chai' ;
4
+ import sinon from 'sinon' ;
5
+ import Component from '../../src/notifications' ;
4
6
import NotifySystem from 'react-notification-system' ;
5
7
6
8
describe ( 'NotificationsComponent' , ( ) => {
7
9
it ( 'should render one <NotifySystem /> component' , ( ) => {
8
10
const wrapper = shallow ( < Component /> ) ;
9
- expect ( wrapper . children ( ) ) . toBeDefined ( ) ;
11
+ expect ( wrapper . children ( ) ) . to . exist ;
10
12
} ) ;
11
13
12
14
it ( 'should warn if prop:notifications is not array' , ( ) => {
13
- spyOn ( console , 'error' ) ;
15
+ const c = sinon . stub ( console , 'error' ) ;
14
16
15
17
const wrapper = shallow ( < Component notifications = { 1 } /> ) ;
16
- const warning = console . error . calls . argsFor ( 0 ) [ 0 ] ;
18
+ const warning = c . args [ 0 ] [ 0 ] ;
17
19
18
- expect ( warning ) . toMatch ( / I n v a l i d p r o p ` n o t i f i c a t i o n s ` o f t y p e ` n u m b e r ` s u p p l i e d t o ` N o t i f i c a t i o n s ` , e x p e c t e d ` a r r a y ` ./ ) ;
20
+ expect ( warning ) . to . match ( / I n v a l i d p r o p ` n o t i f i c a t i o n s ` o f t y p e ` n u m b e r ` s u p p l i e d t o ` N o t i f i c a t i o n s ` , e x p e c t e d ` a r r a y ` ./ ) ;
21
+
22
+ c . restore ( ) ;
19
23
} ) ;
20
24
} ) ;
Original file line number Diff line number Diff line change 1
- import Reducer from '../reducer' ;
2
- import * as Actions from '../actions' ;
1
+ import { expect } from 'chai' ;
2
+
3
+ import Reducer from '../../src/reducer' ;
4
+ import * as Actions from '../../src/actions' ;
3
5
4
6
describe ( 'reducer' , ( ) => {
5
7
it ( 'initializes state with an array' , ( ) => {
6
- expect ( Reducer ( ) ) . toEqual ( [ ] ) ;
8
+ expect ( Reducer ( ) ) . to . deep . equal ( [ ] ) ;
7
9
} ) ;
8
10
9
11
it ( 'stores the notification to state' , ( ) => {
10
12
const action = Actions . success ( ) ;
11
13
const state = Reducer ( [ ] , action ) ;
12
14
13
- expect ( state . length ) . toEqual ( 1 ) ;
15
+ expect ( state . length ) . to . equal ( 1 ) ;
14
16
} ) ;
15
17
16
18
it ( 'stores and removes notification' , ( ) => {
17
19
const uid = 1 ;
18
20
19
21
const state = Reducer ( [ ] , Actions . success ( { uid } ) ) ;
20
- expect ( state . length ) . toEqual ( 1 ) ;
22
+ expect ( state . length ) . to . equal ( 1 ) ;
21
23
22
24
const newState = Reducer ( state , Actions . hide ( uid ) ) ;
23
- expect ( newState . length ) . toEqual ( 0 ) ;
25
+ expect ( newState . length ) . to . equal ( 0 ) ;
24
26
} ) ;
25
27
} ) ;
Original file line number Diff line number Diff line change
1
+ --compilers js:babel-register
2
+ --require test/utils/dom.js
3
+ --reporter spec
Original file line number Diff line number Diff line change
1
+ const jsdom = require ( 'jsdom' ) ;
2
+
3
+ // setup the simplest document possible
4
+ const doc = jsdom . jsdom ( '<!doctype html><html><body></body></html>' ) ;
5
+
6
+ // get the window object out of the document
7
+ const win = doc . defaultView ;
8
+
9
+ // set globals for mocha that make access to document and window feel
10
+ // natural in the test environment
11
+ global . document = doc ;
12
+ global . window = win ;
13
+
14
+ //JSDOM doesn't support localStrage by default, so lets just fake it..
15
+ if ( ! global . window . localStorage ) {
16
+ global . window . localStorage = {
17
+ getItem ( ) { return '{}' ; } ,
18
+ setItem ( ) { }
19
+ } ;
20
+ }
21
+
22
+ // take all properties of the window object and also attach it to the
23
+ // mocha global object
24
+ propagateToGlobal ( win ) ;
25
+
26
+ // from mocha-jsdom https://github.com/rstacruz/mocha-jsdom/blob/master/index.js#L80
27
+ function propagateToGlobal ( window ) {
28
+ for ( let key in window ) {
29
+ if ( ! window . hasOwnProperty ( key ) ) continue ;
30
+ if ( key in global ) continue ;
31
+
32
+ global [ key ] = window [ key ] ;
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments