File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 1+ jest . dontMock ( '../clamp.js' ) ;
2+
3+ var clamp = require ( '../clamp' ) ;
4+
5+ describe ( 'clamp' , function ( ) {
6+ it ( 'returns the min if n is less than min' , function ( ) {
7+ expect ( clamp ( - 1 , 0 , 1 ) ) . toBe ( 0 ) ;
8+ } ) ;
9+
10+ it ( 'returns the max if n is greater than max' , function ( ) {
11+ expect ( clamp ( 2 , 0 , 1 ) ) . toBe ( 1 ) ;
12+ } ) ;
13+
14+ it ( 'returns n if n is between min and max' , function ( ) {
15+ expect ( clamp ( 0.5 , 0 , 1 ) ) . toBe ( 0.5 ) ;
16+ } ) ;
17+ } ) ;
Original file line number Diff line number Diff line change 1010module . exports = function ( number , min , max ) {
1111 return Math . min ( Math . max ( number , min ) , max ) ;
1212} ;
13-
Original file line number Diff line number Diff line change 88 "url" : " https://github.com/Flipboard/react-canvas.git"
99 },
1010 "scripts" : {
11- "start" : " ./node_modules/.bin/gulp"
11+ "start" : " ./node_modules/.bin/gulp" ,
12+ "test" : " ./node_modules/.bin/jest"
1213 },
1314 "keywords" : [
1415 " react" ,
2627 "gulp" : " ^3.8.10" ,
2728 "gulp-connect" : " ^2.2.0" ,
2829 "gulp-webpack" : " ^1.2.0" ,
30+ "jest-cli" : " ^0.2.2" ,
2931 "jsx-loader" : " ^0.12.2" ,
3032 "react" : " ^0.13.0-beta.1" ,
3133 "transform-loader" : " ^0.2.1" ,
You can’t perform that action at this time.
0 commit comments