Skip to content

Commit

Permalink
✅ raise coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tokyo committed Oct 14, 2020
1 parent fc83720 commit aeabc30
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<img src="https://img.shields.io/npm/v/micro-geoip-lite.svg"></img>
<img src="https://img.shields.io/npm/dt/micro-geoip-lite.svg"></img>
</a>
<a href="https://codecov.io/gh/A-Tokyo/micro-geoip-lite">
<img src="https://img.shields.io/codecov/c/github/a-tokyo/micro-geoip-lite.svg"></img>
<a href="https://codecov.io/gh/A-Tokyo/micro-geoip-lite-js">
<img src="https://img.shields.io/codecov/c/github/a-tokyo/micro-geoip-lite-js.svg"></img>
</a>
<a href="https://twitter.com/intent/follow?screen_name=ahmad_tokyo"><img src="https://img.shields.io/twitter/follow/ahmad_tokyo.svg?label=Follow%20@ahmad_tokyo" alt="Follow @ahmad_tokyo"></img></a>

Expand Down
19 changes: 19 additions & 0 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,25 @@ describe('index Test', () => {
});

it('Returns proper schema with timeout', async () => {
const result = await geodecodeIp('207.97.227.239', { timeout: 1000 * 3 });
expect(result).toEqual(
expect.objectContaining({
ip: '207.97.227.239',
range: [3479298048, 3479302143],
country: 'US',
region: 'TX',
eu: '0',
timezone: 'America/Chicago',
city: 'San Antonio',
ll: [29.4963, -98.4004],
metro: 641,
area: 1000,
}),
);
expect(result.error).toEqual(undefined);
});

it('Returns proper schema with timeout AND NO IP', async () => {
const result = await geodecodeIp(undefined, { timeout: 1000 * 3 });
expect(result).toEqual(
expect.objectContaining({
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const geodecodeIp = (
error?: string,
}> =>
ky(
`${serviceUrl || SERVICE_URL_GEOIP}${
ip ? `?ip=${ip}${timeout ? `&timeout=${timeout}` : ''}` : ''
`${serviceUrl || SERVICE_URL_GEOIP}${ip ? `?ip=${ip}` : ''}${
timeout ? `${ip ? '&' : '?'}timeout=${timeout}` : ''
}`,
)
.then((res) => res.json())
Expand Down

0 comments on commit aeabc30

Please sign in to comment.