-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Mocha Testing and Github Testing + Publish Actions (#12)
* tests done * more files * add action for testing * add on commands * add publish * run test on pull request * update version for release * publish on main branch, manually * remove branch in publish * run publish on release * add to tests * add testing package * revert badge
- Loading branch information
1 parent
7b7d5b3
commit e6bdb13
Showing
9 changed files
with
674 additions
and
24 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Publish Package | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
- run: yarn | ||
- run: yarn run test | ||
env: | ||
PDL_API_KEY: ${{secrets.PDL_API_KEY}} | ||
|
||
publish-npm: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: yarn | ||
- run: yarn run pub | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Test Package | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
- run: yarn | ||
- run: yarn run test | ||
env: | ||
PDL_API_KEY: ${{secrets.PDL_API_KEY}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
import { expect } from 'chai'; | ||
import dotenv from 'dotenv'; | ||
import PDLJS from '../dist/index.m.js'; | ||
|
||
dotenv.config({ path: './.env.local' }); | ||
|
||
const PDLJSClient = new PDLJS({ apiKey: process.env.PDL_API_KEY }); | ||
|
||
const phone = '4155688415'; | ||
|
||
const records = { | ||
requests: [ | ||
{ | ||
params: { | ||
profile: ['linkedin.com/in/seanthorne'], | ||
}, | ||
}, | ||
{ | ||
params: { | ||
profile: ['linkedin.com/in/randrewn'], | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
const personSQL = "SELECT * FROM person WHERE location_country='mexico' AND job_title_role='health'AND phone_numbers IS NOT NULL;"; | ||
|
||
const personElastic = { | ||
query: { | ||
bool: { | ||
must: [ | ||
{ term: { location_country: 'mexico' } }, | ||
{ term: { job_title_role: 'health' } }, | ||
{ exists: { field: 'phone_numbers' } }, | ||
], | ||
}, | ||
}, | ||
}; | ||
|
||
const personID = 'qEnOZ5Oh0poWnQ1luFBfVw_0000'; | ||
|
||
const website = 'peopledatalabs.com'; | ||
|
||
const companySQL = "SELECT * FROM company WHERE tags='big data' AND industry='financial services' AND location.country='united states';"; | ||
|
||
const companyElastic = { | ||
query: { | ||
bool: { | ||
must: [ | ||
{ term: { website: 'peopledatalabs.com' } }, | ||
], | ||
}, | ||
}, | ||
}; | ||
|
||
const autocomplete = { | ||
field: 'skill', | ||
text: 'c++', | ||
size: 10, | ||
}; | ||
|
||
const company = { name: 'peopledatalabs' }; | ||
|
||
const location = { location: '455 Market Street, San Francisco, California 94105, US' }; | ||
|
||
const school = { name: 'university of oregon' }; | ||
|
||
describe('Person Enrichment', () => { | ||
it(`Should Return Person Record for ${phone}`, (done) => { | ||
PDLJSClient.person.enrichment({ phone }).then((data) => { | ||
expect(data.status).to.equal(200); | ||
expect(data).to.be.a('object'); | ||
done(); | ||
}).catch((error) => { | ||
expect(error).to.be.a('string'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Person Identify', () => { | ||
it(`Should Return Person Record for ${phone}`, (done) => { | ||
PDLJSClient.person.identify({ phone: '4155688415' }).then((data) => { | ||
expect(data.status).to.equal(200); | ||
expect(data).to.be.a('object'); | ||
done(); | ||
}).catch((error) => { | ||
expect(error).to.be.a('string'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Person Bulk', () => { | ||
it(`Should Return Person Records for ${JSON.stringify(records)}`, (done) => { | ||
PDLJSClient.person.bulk(records).then((data) => { | ||
expect(data.length).to.equal(2); | ||
expect(data).to.be.a('array'); | ||
done(); | ||
}).catch((error) => { | ||
expect(error).to.be.a('string'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Person Search', () => { | ||
it(`Should Return Person Records for ${personSQL}`, (done) => { | ||
PDLJSClient.person.search.sql({ searchQuery: personSQL, size: 10 }).then((data) => { | ||
expect(data.status).to.equal(200); | ||
expect(data).to.be.a('object'); | ||
done(); | ||
}).catch((error) => { | ||
expect(error).to.be.a('string'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it(`Should Return Person Records for ${JSON.stringify(personElastic)}`, (done) => { | ||
PDLJSClient.person.search.elastic({ searchQuery: personElastic, size: 10 }).then((data) => { | ||
expect(data.status).to.equal(200); | ||
expect(data).to.be.a('object'); | ||
done(); | ||
}).catch((error) => { | ||
expect(error).to.be.a('string'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Person Retrieve', () => { | ||
it(`Should Return Person Record for ${personID}`, (done) => { | ||
PDLJSClient.person.retrieve(personID).then((data) => { | ||
expect(data.status).to.equal(200); | ||
expect(data).to.be.a('object'); | ||
done(); | ||
}).catch((error) => { | ||
expect(error).to.be.a('string'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Company Enrichment', () => { | ||
it(`Should Return Company Record for ${website}`, (done) => { | ||
PDLJSClient.company.enrichment({ website }).then((data) => { | ||
expect(data.status).to.equal(200); | ||
expect(data).to.be.a('object'); | ||
done(); | ||
}).catch((error) => { | ||
expect(error).to.be.a('string'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Company Search', () => { | ||
it(`Should Return Company Records for ${companySQL}`, (done) => { | ||
PDLJSClient.company.search.sql({ searchQuery: companySQL, size: 10 }).then((data) => { | ||
expect(data.status).to.equal(200); | ||
expect(data).to.be.a('object'); | ||
done(); | ||
}).catch((error) => { | ||
expect(error).to.be.a('string'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it(`Should Return Company Records for ${JSON.stringify(companyElastic)}`, (done) => { | ||
PDLJSClient.company.search.elastic({ searchQuery: companyElastic, size: 10 }).then((data) => { | ||
expect(data.status).to.equal(200); | ||
expect(data).to.be.a('object'); | ||
done(); | ||
}).catch((error) => { | ||
expect(error).to.be.a('string'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Autocomplete', () => { | ||
it(`Should Return Autocomplete Records for ${JSON.stringify(autocomplete)}`, (done) => { | ||
PDLJSClient.autocomplete(autocomplete).then((data) => { | ||
expect(data.status).to.equal(200); | ||
expect(data).to.be.a('object'); | ||
done(); | ||
}).catch((error) => { | ||
expect(error).to.be.a('string'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Cleaner APIs', () => { | ||
it(`Should Return Company Cleaner Records for ${JSON.stringify(company)}`, (done) => { | ||
PDLJSClient.company.cleaner(company).then((data) => { | ||
expect(data.status).to.equal(200); | ||
expect(data).to.be.a('object'); | ||
done(); | ||
}).catch((error) => { | ||
expect(error).to.be.a('string'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it(`Should Return Location Cleaner Records for ${JSON.stringify(location)}`, (done) => { | ||
PDLJSClient.location.cleaner(location).then((data) => { | ||
expect(data.status).to.equal(200); | ||
expect(data).to.be.a('object'); | ||
done(); | ||
}).catch((error) => { | ||
expect(error).to.be.a('string'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it(`Should Return School Cleaner Records for ${JSON.stringify(school)}`, (done) => { | ||
PDLJSClient.school.cleaner(school).then((data) => { | ||
expect(data.status).to.equal(200); | ||
expect(data).to.be.a('object'); | ||
done(); | ||
}).catch((error) => { | ||
expect(error).to.be.a('string'); | ||
done(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.