'use strict';

var expect = require('chai').expect;
var nock   = require('nock');
var Client = require('../src/client');

describe('Person', function () {

  var client = new Client({key: 'k'});
  var Person = require('../src/person')(client);

  var mock;
  before(function () {
    mock = nock('https://person.clearbit.co');
  });
  after(nock.cleanAll);
  afterEach(function () {
    mock.done();
  });

  describe('#pending', function () {

    it('identifies whether the person has an id', function () {
      var person = new Person();
      expect(person.pending()).to.be.true;
      person.id = 'foo';
      expect(person.pending()).to.be.false;
    });

  });

  describe('Person#find', function () {

    it('can find a person by email', function () {
      var alex = require('./fixtures/person');
      mock
        .get('/v1/people/email/alex@alexmaccaw.com')
        .reply(200, alex);
      return Person.find({email: 'alex@alexmaccaw.com'})
        .then(function (person) {
          expect(person)
            .to.be.an.instanceOf(Person)
            .and.have.property('id', alex.id);
        });
    });

  });

});
@@ -1114,22 +1114,495 @@
 );%0A    %7D);%0A%0A
+    it('can subscribe to a person', function () %7B%0A      mock%0A        .get('/v1/people/email/alex@alexmaccaw.com?subscribe=true')%0A        .reply(200);%0A      return Person.find(%7Bemail: 'alex@alexmaccaw.com', subscribe: true%7D);%0A    %7D);%0A%0A    it('can override the company setting', function () %7B%0A      mock%0A        .get('/v1/people/email/alex@alexmaccaw.com?company=false')%0A        .reply(200);%0A      return Person.find(%7Bemail: 'alex@alexmaccaw.com', company: false%7D);%0A    %7D);%0A%0A
   %7D);%0A%0A%7D);
@@ -1601,8 +1601,9 @@
 %7D);%0A%0A%7D);
+%0A

Test ability to change query parameters for a Person#find call