import * as sinon from "sinon" ; import { SinonSandbox } from "sinon" ; import { NodeUtil } from "../../lib/core/node-util" ; describe ( "bst-sleep" , function ( ) { let sandbox = null ; beforeEach ( function ( ) { delete require . cache [ require . resolve ( "commander" ) ] ; sandbox = sinon . sandbox . create ( ) ; sandbox . stub ( process , "exit" , function ( ) { } ) ; } ) ; afterEach ( function ( ) { sandbox . restore ( ) ; } ) ; describe ( "sleep command" , function ( ) { it ( "sleep with no-args" , function ( done ) { process . argv = command ( "node bst-sleep.js" ) ; sandbox . stub ( process . stdout , "write" , function ( data ? ) { if ( data !== undefined && data . indexOf ( "Instructs" ) !== - 1 ) { done ( ) ; } } ) ; NodeUtil . run ( "../../bin/bst-sleep.js" ) ; } ) ; it ( "sleep with non-brooklyn" , function ( done ) { process . argv = command ( "node bst-sleep.js NotBrooklyn" ) ; sandbox . stub ( console , "log" , function ( data ? ) { if ( data !== undefined && data . indexOf ( "Did you know" ) !== - 1 ) { done ( ) ; } } ) ; NodeUtil . run ( "../../bin/bst-sleep.js" ) ; } ) ; it ( "sleep with brooklyn" , function ( done ) { process . argv = command ( "node bst-sleep.js brooklyn" ) ; sandbox . stub ( console , "log" , function ( data ? ) { if ( data !== undefined && data . indexOf ( "Yeah" ) !== - 1 ) { done ( ) ; } } ) ; NodeUtil . run ( "../../bin/bst-sleep.js" ) ; } ) ; } ) ; } ) ; let command = function ( c ) : Array < string > { return c . split ( " " ) ; } ;