<commit_before>
var Client = require('../index').Client;
var Transport = require('./mock/Transport');
var OutgoingFrameStream = require('./mock/OutgoingFrameStream');
var assert = require('assert');

describe('Client.connect', function() {

  var client, transport, framesOut, framesIn;

  beforeEach(function() {

    transport = new Transport();
    framesOut = new OutgoingFrameStream();

    client = new Client(transport, {
      outgoingFrameStream: framesOut
    });
  });

  it('should send a CONNECT frame and include accept-version header', function(done) {

    client.connect();

    assert(framesOut._frames[0]);

    var frame = framesOut._frames[0];

    assert.equal(frame.command, 'CONNECT');
    assert('accept-version' in frame.headers);

    assert.equal(frame._finished, true);
    assert.equal(frame._body.length, 0);
    
    done();
  });

});<commit_msg>Test for heart-beat header handling<commit_after>
var Client = require('../index').Client;
var Transport = require('./mock/Transport');
var OutgoingFrameStream = require('./mock/OutgoingFrameStream');
var assert = require('assert');

describe('Client.connect', function() {

  var client, transport, framesOut, framesIn;

  beforeEach(function() {

    transport = new Transport();
    framesOut = new OutgoingFrameStream();

    client = new Client(transport, {
      outgoingFrameStream: framesOut
    });
  });

  it('should send a CONNECT frame and include accept-version header', function(done) {

    client.connect();

    assert(framesOut._frames[0]);

    var frame = framesOut._frames[0];

    assert.equal(frame.command, 'CONNECT');
    assert('accept-version' in frame.headers);

    assert.equal(frame._finished, true);
    assert.equal(frame._body.length, 0);
    
    done();
  });

  it('should parse the heart-beat header and call setHeartbeat', function(done) {

    client.connect({
      'heart-beat': '1,2'
    });

    var heartbeat = client.getHeartbeat();

    assert.equal(heartbeat[0], 1);
    assert.equal(heartbeat[1], 2);

    assert.equal(framesOut._frames[0].headers['heart-beat'], '1,2');

    done();
  });
});
{'fraction_non_alphanumeric': 0.15457115928369464, 'fraction_numerical': 0.00706880301602262, 'mean_word_length': 3.835990888382688, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1840864', 'n_tokens_mistral': 640, 'n_tokens_neox': 604, 'n_words': 140}