Pushing changes
This commit is contained in:
		
							
								
								
									
										30
									
								
								node_modules/reduce-component/test/index.html
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								node_modules/reduce-component/test/index.html
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| <html> | ||||
| <head> | ||||
|   <title>reduce component</title> | ||||
| </head> | ||||
| <body> | ||||
|   <script src="../build/build.js"></script> | ||||
|   <script> | ||||
|     var reduce = require('reduce'); | ||||
|      | ||||
|     var items = [0, 1, 2, 3, 4, 5]; | ||||
|     var none = []; | ||||
|  | ||||
|     var a = reduce(items, concat); | ||||
|     var b = reduce(items, sum); | ||||
|     var c = reduce(items, sum, 10); | ||||
|  | ||||
|     console.log('concat: %s', a); | ||||
|     console.log('sum: %s', b); | ||||
|     console.log('sum + 10: %s', c); | ||||
|  | ||||
|     function concat(prev, curr, idx, arr) { | ||||
|       return String(prev) + String(curr);  | ||||
|     } | ||||
|  | ||||
|     function sum(prev, curr){ | ||||
|       return prev + curr; | ||||
|     } | ||||
|   </script> | ||||
| </body> | ||||
| </html> | ||||
							
								
								
									
										49
									
								
								node_modules/reduce-component/test/reduce.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								node_modules/reduce-component/test/reduce.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,49 @@ | ||||
|  | ||||
| var reduce = require('..'); | ||||
|  | ||||
| describe('reduce', function(){ | ||||
|  | ||||
|   describe('when adding prev and current', function(){ | ||||
|     it('should be sum all the values', function(){ | ||||
|       var numbers = [2,2,2]; | ||||
|       var fn = function(prev, curr){ | ||||
|         return prev + curr; | ||||
|       }; | ||||
|  | ||||
|       var a = numbers.reduce(fn); | ||||
|       var b = reduce(numbers, fn); | ||||
|  | ||||
|       a.should.equal(6); | ||||
|       b.should.equal(a); | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
|   describe('when passing in an initial value', function(){ | ||||
|     it('should default to it', function(){ | ||||
|       var items = []; | ||||
|       var fn = function(prev){ | ||||
|         return prev; | ||||
|       }; | ||||
|  | ||||
|       var a = items.reduce(fn, 'foo'); | ||||
|       var b = reduce(items, fn, 'foo'); | ||||
|  | ||||
|       a.should.equal('foo'); | ||||
|       b.should.equal(a); | ||||
|     }); | ||||
|  | ||||
|     it('should start with it', function(){ | ||||
|       var items = [10, 10]; | ||||
|       var fn = function(prev, curr){ | ||||
|         return prev + curr; | ||||
|       }; | ||||
|  | ||||
|       var a = items.reduce(fn, 10); | ||||
|       var b = reduce(items, fn, 10); | ||||
|  | ||||
|       a.should.equal(30); | ||||
|       b.should.equal(a); | ||||
|     }); | ||||
|   }); | ||||
|  | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user