Commit a399b6c7 by Alex MacCaw

add tests

parent 110c779f
{
"name": "clearbit",
"version": "1.2.1",
"version": "1.2.3",
"description": "Client for Clearbit.co business intelligence APIs",
"main": "./src",
"scripts": {
......
......@@ -3,7 +3,7 @@
var resource = require('./resource');
exports.Risk = resource.create('Risk', {
api: 'Risk'
api: 'risk'
})
.extend(null, {
calculate: function(options) {
......
{
"email": {
"valid": true,
"socialMatch": true,
"companyMatch": true,
"nameMatch": null,
"disposable": false,
"freeProvider": false,
"confirmed": false,
"blacklisted": false
},
"address": {
"geoMatch": null
},
"ip": {
"proxy": false,
"geoMatch": null,
"blacklisted": false
},
"risk": {
"level": "low",
"score": 0
}
}
'use strict';
var expect = require('chai').expect;
var nock = require('nock');
var Risk = require('../')('k').Risk;
describe('Risk', function () {
var mock;
before(function () {
mock = nock('https://risk.clearbit.com');
});
after(nock.cleanAll);
afterEach(function () {
mock.done();
});
describe('Risk#search', function () {
var fixture = require('./fixtures/risk');
it('can calculate risk', function () {
mock
.get('/v1/calculate?email=alex%40clearbit.com&ip=127.0.0.1')
.reply(200, fixture);
return Risk.calculate({email: 'alex@clearbit.com', ip: '127.0.0.1'})
.then(function (response) {
expect(response)
.to.be.an.instanceOf(Risk)
.and.have.deep.property('risk.score', fixture.risk.score);
});
});
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment