Skip to content

Commit b6a317d

Browse files
committed
fix: use ipdata api key for testing
1 parent d894bfb commit b6a317d

4 files changed

Lines changed: 82 additions & 8 deletions

File tree

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
- name: Install dependencies
2626
run: npm ci
2727
- name: Test
28+
env:
29+
IPDATA_API_KEY: ${{ secrets.IPDATA_API_KEY }}
2830
run: npm test
2931

3032
release:

package-lock.json

Lines changed: 74 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"prebuild": "del lib",
88
"build": "tsc",
99
"lint": "eslint --fix \"src/**\"",
10-
"test": "jest"
10+
"test": "dotenv jest"
1111
},
1212
"repository": {
1313
"type": "git",
@@ -37,6 +37,7 @@
3737
"@typescript-eslint/eslint-plugin": "^2.4.0",
3838
"@typescript-eslint/parser": "^2.4.0",
3939
"del-cli": "^3.0.0",
40+
"dotenv-cli": "3.0.0",
4041
"eslint": "^6.5.1",
4142
"eslint-config-airbnb-base": "^14.0.0",
4243
"eslint-config-prettier": "^6.4.0",

test/ipdata.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import IPData from '../src/ipdata';
22

3-
const API_KEY = 'test';
4-
53
describe('constructor()', () => {
64
it('should throw an error if an apiKey is not provided', () => {
75
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
@@ -10,13 +8,13 @@ describe('constructor()', () => {
108
});
119

1210
it('should set the apiKey', () => {
13-
const ipdata = new IPData(API_KEY);
14-
expect(ipdata.apiKey).toEqual(API_KEY);
11+
const ipdata = new IPData(process.env.IPDATA_API_KEY);
12+
expect(ipdata.apiKey).toEqual(process.env.IPDATA_API_KEY);
1513
});
1614
})
1715

1816
describe('lookup()', () => {
19-
const ipdata = new IPData(API_KEY);
17+
const ipdata = new IPData(process.env.IPDATA_API_KEY);
2018
const IP = '1.1.1.1';
2119

2220
afterEach(() => {
@@ -106,7 +104,7 @@ describe('lookup()', () => {
106104
});
107105

108106
describe('bulkLookup()', () => {
109-
const ipdata = new IPData(API_KEY);
107+
const ipdata = new IPData(process.env.IPDATA_API_KEY);
110108
const IP1 = '1.1.1.1';
111109
const IP2 = '8.8.8.8';
112110

0 commit comments

Comments
 (0)