 
   it 'should parse a single, full frame', ->
     frameBuffer = new FrameBuffer()
-    data = createFrame message.FRAME_TYPE_RESPONSE, 'OK'
+    data = createFrame wire.FRAME_TYPE_RESPONSE, 'OK'
     frames = frameBuffer.consume data
 
     [frameId, payload] = frames.pop()
-    frameId.should.eq message.FRAME_TYPE_RESPONSE
+    frameId.should.eq wire.FRAME_TYPE_RESPONSE
     payload.toString().should.eq 'OK'
 
   it 'should parse two full frames', ->
     frameBuffer = new FrameBuffer()
 
-    firstFrame = createFrame message.FRAME_TYPE_RESPONSE, 'OK'
-    secondFrame = createFrame message.FRAME_TYPE_ERROR,
+    firstFrame = createFrame wire.FRAME_TYPE_RESPONSE, 'OK'
+    secondFrame = createFrame wire.FRAME_TYPE_ERROR,
       JSON.stringify {shortname: 'localhost'}
 
     frames = frameBuffer.consume Buffer.concat [firstFrame, secondFrame]
     frames.length.should.eq 2
 
     [frameId, data] = frames.shift()
-    frameId.should.eq message.FRAME_TYPE_RESPONSE
+    frameId.should.eq wire.FRAME_TYPE_RESPONSE
     data.toString().should.eq 'OK'
 
     [frameId, data] = frames.shift()
-    frameId.should.eq message.FRAME_TYPE_ERROR
+    frameId.should.eq wire.FRAME_TYPE_ERROR
     data.toString().should.eq JSON.stringify {shortname: 'localhost'}
 
   it 'should parse frame delivered in partials', ->
     frameBuffer = new FrameBuffer()
-    data = createFrame message.FRAME_TYPE_RESPONSE, 'OK'
+    data = createFrame wire.FRAME_TYPE_RESPONSE, 'OK'
 
     # First frame is 10 bytes long. Don't expect to get anything back.
     frames = frameBuffer.consume data[0...3]

chai.use sinonChai 

FrameBuffer = require '../lib/framebuffer.coffee'
message = require '../lib/message'

createFrame = (frameId, payload) ->
  frame = new Buffer(4 + 4 + payload.length)


  it 'empty internal buffer when all frames are consumed', ->
    frameBuffer = new FrameBuffer()
    data = createFrame wire.FRAME_TYPE_RESPONSE, 'OK'
    
    frame = frameBuffer.consume data
    expect(frameBuffer._buffer).to.be.null
