 fs = require('fs')
+util = require('util')
 
 lodash = require('lodash')
 debug = require('debug')

        if @expectIndex >= @descriptor.expect.length
            return 2
        currentExpect = @descriptor.expect[@expectIndex]
        if eventName isnt currentExpect.event
            return 1
        if currentExpect.containsText
            if not @_matchText(args, currentExpect.containsText)

    getExpectingEventName : ()->
        if @expectIndex >= @descriptor.expect.length
            return null
        expectedEvent = @descriptor.expect[@expectIndex].event
        if typeof expectedEvent is 'string'
            return expectedEvent
        if util.isArray(expectedEvent)
            return expectedEvent.join(' or ')
        return null
        
    # 1 means waiting, 2 means fully matched
    # we are not reject anything, if the expected event
    # does not showup, we will detect a timeout for waiting
