Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
clearbit
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
prospector
clearbit
Commits
8e7e042e
Commit
8e7e042e
authored
Oct 10, 2014
by
Ben Drucker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Company for domain lookups
parent
f7b79532
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
0 deletions
+90
-0
company.js
src/company.js
+30
-0
company.js
test/company.js
+60
-0
No files found.
src/company.js
0 → 100644
View file @
8e7e042e
'use strict'
;
var
assert
=
require
(
'assert'
);
var
_
=
require
(
'lodash'
);
module
.
exports
=
function
(
client
)
{
function
Company
(
data
)
{
_
.
extend
(
this
,
data
);
}
Company
.
prototype
.
pending
=
function
()
{
return
!
this
.
id
;
};
Company
.
find
=
function
(
options
)
{
assert
(
options
&&
options
.
domain
,
'A domain must be provided'
);
return
this
.
client
.
request
(
_
.
extend
({
api
:
'company'
,
path
:
'/companies/domain/'
+
options
.
domain
},
options
))
.
bind
(
this
)
.
then
(
function
(
data
)
{
return
new
this
(
data
);
});
};
Company
.
prototype
.
client
=
Company
.
client
=
client
;
return
Company
;
};
test/company.js
0 → 100644
View file @
8e7e042e
'use strict'
;
var
expect
=
require
(
'chai'
).
expect
;
var
nock
=
require
(
'nock'
);
var
Client
=
require
(
'../src/client'
);
describe
(
'Company'
,
function
()
{
var
client
=
new
Client
({
key
:
'k'
});
var
Company
=
require
(
'../src/company'
)(
client
);
var
mock
;
before
(
function
()
{
mock
=
nock
(
'https://company.clearbit.co'
);
});
after
(
nock
.
cleanAll
);
afterEach
(
function
()
{
mock
.
done
();
});
describe
(
'#pending'
,
function
()
{
it
(
'identifies whether the company has an id'
,
function
()
{
var
company
=
new
Company
();
expect
(
company
.
pending
()).
to
.
be
.
true
;
company
.
id
=
'foo'
;
expect
(
company
.
pending
()).
to
.
be
.
false
;
});
});
describe
(
'Company#find'
,
function
()
{
var
company
=
require
(
'./fixtures/company'
);
it
(
'can find a company by domain'
,
function
()
{
mock
.
get
(
'/v1/companies/domain/uber.com'
)
.
reply
(
200
,
company
);
return
Company
.
find
({
domain
:
'uber.com'
})
.
then
(
function
(
company
)
{
expect
(
company
)
.
to
.
be
.
an
.
instanceOf
(
Company
)
.
and
.
have
.
property
(
'id'
,
company
.
id
);
});
});
it
(
'is can handle pending requests'
,
function
()
{
mock
.
get
(
'/v1/companies/domain/uber.com'
)
.
reply
(
202
);
return
Company
.
find
({
domain
:
'uber.com'
})
.
then
(
function
(
company
)
{
expect
(
company
.
pending
()).
to
.
be
.
true
;
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment