<commit_before>'use strict'

var expect = require('expect.js')
var fs = require('fs')
var path = require('path')
var sshConfig = require('..')


describe('ssh-config', function() {
  var fixture = fs.readFileSync(path.join(__dirname, 'fixture/config'), 'utf-8')
    .replace(/\r\n/g, '\n')
  var config = sshConfig.parse(fixture)

  it('.parse ssh config text into object', function() {
    expect(config.ControlMaster).to.equal('auto')
    expect(config.length).to.equal(4)

    expect(config[0]).to.eql({
      Host: 'tahoe1',
      HostName: 'tahoe1.com',
      Compression: 'yes'
    })
  })

  it('.query ssh config by host', function() {
    var opts = config.query('tahoe2')

    expect(opts.User).to.equal('nil')
    expect(opts.IdentityFile).to.equal('~/.ssh/id_rsa')

    // the first obtained parameter value will be used. So there's no way to
    // override parameter values.
    expect(opts.ServerAliveInterval).to.eql(80)

    opts = config.query('tahoe1')
    expect(opts.User).to.equal('nil')
    expect(opts.ForwardAgent).to.equal('true')
    expect(opts.Compression).to.equal('yes')
  })

  it('.stringify the parsed object back to string', function() {
    expect(fixture).to.contain(sshConfig.stringify(config))
  })
})<commit_msg>Shall check HostName in the returned object<commit_after>'use strict'

var expect = require('expect.js')
var fs = require('fs')
var path = require('path')
var sshConfig = require('..')


describe('ssh-config', function() {
  var fixture = fs.readFileSync(path.join(__dirname, 'fixture/config'), 'utf-8')
    .replace(/\r\n/g, '\n')
  var config = sshConfig.parse(fixture)

  it('.parse ssh config text into object', function() {
    expect(config.ControlMaster).to.equal('auto')
    expect(config.length).to.equal(4)

    expect(config[0]).to.eql({
      Host: 'tahoe1',
      HostName: 'tahoe1.com',
      Compression: 'yes'
    })
  })

  it('.query ssh config by host', function() {
    var opts = config.query('tahoe2')

    expect(opts.User).to.equal('nil')
    expect(opts.IdentityFile).to.equal('~/.ssh/id_rsa')

    // the first obtained parameter value will be used. So there's no way to
    // override parameter values.
    expect(opts.ServerAliveInterval).to.eql(80)

    opts = config.query('tahoe1')
    expect(opts.HostName).to.equal('tahoe1.com')
    expect(opts.User).to.equal('nil')
    expect(opts.ForwardAgent).to.equal('true')
    expect(opts.Compression).to.equal('yes')
  })

  it('.stringify the parsed object back to string', function() {
    expect(fixture).to.contain(sshConfig.stringify(config))
  })
})
{'fraction_non_alphanumeric': 0.17421602787456447, 'fraction_numerical': 0.007355787843592722, 'mean_word_length': 3.664259927797834, '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': '736917', 'n_tokens_mistral': 889, 'n_tokens_neox': 842, 'n_words': 175}