var assert = require('assert'),
    vows = require('vows'),
    AuthorizedKeys = require('../');

var testKey = { type: 'ssh-rsa', content: 'mykey', name: 'maciej' };

vows.describe('authorized-keys').addBatch({
  'When using `authorized-keys`': {
    'with a new `AuthorizedKeys` object': {
      topic: new AuthorizedKeys(),
      'there should be no keys': function (keys) {
        assert.lengthOf(keys.keys, 0);
      },
      'after adding a key to it': {
        topic: function (keys) {
          keys.add(testKey);
          return keys;
        },
        'it should be there': function (keys) {
          assert.lengthOf(keys.keys, 1);
          assert.deepEqual(keys.keys[0], new AuthorizedKeys.Key(testKey));
        }
      }
    }
  }
}).export(module);


var assert = require('assert'),
    vows = require('vows'),
    AuthorizedKeys = require('../');

var testKey = { type: 'ssh-rsa', content: 'mykey', name: 'maciej' };

vows.describe('authorized-keys').addBatch({
  'When using `authorized-keys`': {
    'with a new `AuthorizedKeys` object': {
      topic: new AuthorizedKeys(),
      'there should be no keys': function (keys) {
        assert.lengthOf(keys.keys, 0);
      },
      'after adding a key to it': {
        topic: function (keys) {
          keys.add(testKey);
          return keys;
        },
        'it should be there': function (keys) {
          assert.lengthOf(keys.keys, 1);
          assert.deepEqual(keys.keys[0], new AuthorizedKeys.Key(testKey));
        },
        'it should be searchable by name': function (keys) {
          var search = keys.getByName(testKey.name);
          assert.lengthOf(search, 1);
          assert.deepEqual(search[0], new AuthorizedKeys.Key(testKey));
        }
      }
    }
  }
}).export(module);


Add test for searching by name
[test] Add test for searching by name
