@k03mad/ip2geo 5.0.0 β 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/lib/ip2geo.js +1 -1
- package/package.json +1 -1
- package/tests/cache-map-off.js +6 -5
- package/tests/helpers/consts.js +12 -0
package/app/lib/ip2geo.js
CHANGED
|
@@ -112,7 +112,7 @@ const writeToFsCache = async (ip, data, cacheDir, cacheFileName, cacheFileSepara
|
|
|
112
112
|
* @param {string} [opts.cacheFileName]
|
|
113
113
|
* @param {string} [opts.cacheFileSeparator]
|
|
114
114
|
* @param {string} [opts.cacheFileNewline]
|
|
115
|
-
* @param {Map
|
|
115
|
+
* @param {Map} [opts.cacheMap]
|
|
116
116
|
* @param {number} [opts.cacheMapMaxEntries]
|
|
117
117
|
* @param {number} [opts.rps]
|
|
118
118
|
* @returns {Promise<GeoIpOutput>}
|
package/package.json
CHANGED
package/tests/cache-map-off.js
CHANGED
|
@@ -4,7 +4,7 @@ import {describe, it} from 'mocha';
|
|
|
4
4
|
|
|
5
5
|
import {cacheStorage, ip2geo} from '../app/index.js';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {REQUEST_IPV4_MAP_OFF_ONLY} from './helpers/consts.js';
|
|
8
8
|
import {getCurrentFilename, getTestFolder} from './helpers/path.js';
|
|
9
9
|
import {checkCacheFile, removeCacheFolder} from './shared/fs.js';
|
|
10
10
|
|
|
@@ -18,13 +18,14 @@ describe(testName, () => {
|
|
|
18
18
|
|
|
19
19
|
it('should remove fs cache dir if exist', () => removeCacheFolder(opts.cacheDir));
|
|
20
20
|
|
|
21
|
-
it(`should return correct response for IP: "${
|
|
22
|
-
const data = await ip2geo(
|
|
23
|
-
assert.deepEqual(data,
|
|
21
|
+
it(`should return correct response for IP: "${REQUEST_IPV4_MAP_OFF_ONLY.ip}"`, async () => {
|
|
22
|
+
const data = await ip2geo(REQUEST_IPV4_MAP_OFF_ONLY.ip, opts);
|
|
23
|
+
assert.deepEqual(data, REQUEST_IPV4_MAP_OFF_ONLY);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
it('should have cache file', () => checkCacheFile({
|
|
27
|
-
|
|
27
|
+
...opts,
|
|
28
|
+
response: REQUEST_IPV4_MAP_OFF_ONLY,
|
|
28
29
|
}));
|
|
29
30
|
|
|
30
31
|
it('should not have cache entries', () => {
|
package/tests/helpers/consts.js
CHANGED
|
@@ -20,6 +20,18 @@ export const REQUEST_IPV4 = {
|
|
|
20
20
|
ispDomain: 'google.com',
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
export const REQUEST_IPV4_MAP_OFF_ONLY = {
|
|
24
|
+
ip: '1.1.1.1',
|
|
25
|
+
emoji: 'πΊπΈ',
|
|
26
|
+
country: 'United States',
|
|
27
|
+
countryA2: 'US',
|
|
28
|
+
region: 'District of Columbia',
|
|
29
|
+
city: 'Washington',
|
|
30
|
+
org: 'APNIC and Cloudflare DNS Resolver project',
|
|
31
|
+
isp: 'Cloudflare, Inc.',
|
|
32
|
+
ispDomain: 'cloudflare.com',
|
|
33
|
+
};
|
|
34
|
+
|
|
23
35
|
export const REQUEST_IPV6 = {
|
|
24
36
|
ip: '2a00:dd80:40:100::',
|
|
25
37
|
emoji: 'π³π±',
|