File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ var Runtime = require ( '../' ) ;
4+
5+ it ( 'runs the callback on completion' , function ( done ) {
6+ var runtime = Runtime . create ( { onHandleError : done } ) ;
7+
8+ var count = 0 ;
9+ function one ( next ) {
10+ ++ count ; next ( ) ;
11+ }
12+ function two ( next ) {
13+ ++ count ; next ( ) ;
14+ }
15+
16+ runtime . compose ( one , two ) ( function ( ) {
17+ count . should . be . eql ( 2 ) ;
18+ done ( ) ;
19+ } ) ;
20+ } ) ;
21+
22+ it ( 'runs functions in parallel by default' , function ( done ) {
23+ var runtime = Runtime . create ( { onHandleError : done } ) ;
24+
25+ var stack = '' ;
26+ function one ( next ) {
27+ setTimeout ( function ( ) {
28+ stack += 'one' ;
29+ next ( ) ;
30+ } , Math . random ( ) * 10 ) ;
31+ }
32+ function two ( next ) {
33+ stack += 'two' ;
34+ next ( ) ;
35+ }
36+
37+ runtime . compose ( one , two ) ( function ( ) {
38+ stack . should . be . eql ( 'twoone' ) ;
39+ done ( ) ;
40+ } ) ;
41+ } ) ;
42+
43+ it ( '{wait: true} runs functions in series' , function ( done ) {
44+ var runtime = Runtime . create ( { onHandleError : done } ) ;
45+
46+ var stack = '' ;
47+ function one ( next ) {
48+ setTimeout ( function ( ) {
49+ stack += 'one' ;
50+ next ( ) ;
51+ } , Math . random ( ) * 10 ) ;
52+ }
53+ function two ( next ) {
54+ stack += 'two' ;
55+ next ( ) ;
56+ }
57+
58+ runtime . compose ( one , two , { wait : true } ) ( function ( ) {
59+ stack . should . be . eql ( 'onetwo' ) ;
60+ done ( ) ;
61+ } ) ;
62+ } ) ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ require ( 'should' ) ;
4+
5+ var fs = require ( 'fs' ) ;
6+ var pack = require ( '../package.json' ) ;
7+
8+ fs . readdirSync ( __dirname ) . forEach ( function ( file ) {
9+ if ( file === 'index.js' ) { return ; }
10+ describe ( pack . name , function ( ) {
11+ describe ( file . split ( '.' ) [ 0 ] , function ( ) {
12+ require ( './' + file ) ;
13+ } ) ;
14+ } ) ;
15+ } ) ;
You can’t perform that action at this time.
0 commit comments