Comparing version 1.0.12 to 1.0.13
17
index.js
@@ -62,2 +62,19 @@ const fs = require('fs'); | ||
}, | ||
dbinfo: async () => { | ||
var ret = {}; | ||
if (!self.db) await self.init(); | ||
return new Promise((resolve, reject) => { | ||
var ln = readline.createInterface({ | ||
input: fs.createReadStream(self.db) | ||
}); | ||
ln.on('line', function (line) { | ||
var m = line.match(/(Publish_Date|Record_Count)/); | ||
if (m) ret[m[1].replace('_', ' ')] = line.replace(/<.*?>/g, '').trim(); | ||
if (ret['Record Count']) { | ||
ln.close(); | ||
resolve(ret); | ||
} | ||
}); | ||
}); | ||
}, | ||
search: async (cust, fn = self.db) => { | ||
@@ -64,0 +81,0 @@ if (!fn) fn = await self.init(); |
{ | ||
"name": "ofac", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"description": "A module to facilitate local OFAC searches", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -91,4 +91,16 @@ var fs = require('fs'); | ||
assert.equal(stats.size, 10128, 'File incomplete') | ||
}); | ||
}); | ||
}) | ||
}) | ||
describe('Archive information', () => { | ||
var info; | ||
before(async () => { | ||
info = await ofac.dbinfo(); | ||
}) | ||
it('Returns publish date', () => { | ||
assert.equal(info['Publish Date'], '03/11/2019', 'Date extraction failed') | ||
}) | ||
it('Returns record count', () => { | ||
assert.equal(info['Record Count'], '7449', 'Record count extraction failed') | ||
}) | ||
}) | ||
describe('Search', () => { | ||
@@ -99,3 +111,3 @@ it('Searched by id/country', async () => { | ||
assert.deepEqual(actual, expected); | ||
}); | ||
}) | ||
it('Searched by id/country with type', async () => { | ||
@@ -105,3 +117,3 @@ var cust = {id: 'J287011', id_type: 'Passport', country: 'Colombia'}; | ||
assert.deepEqual(actual, expected); | ||
}); | ||
}) | ||
it('Searched by id/country with wrong type', async () => { | ||
@@ -111,3 +123,3 @@ var cust = {id: 'J287011', id_type: 'Cedula No.', country: 'Colombia'}; | ||
assert.deepEqual(actual, []); | ||
}); | ||
}) | ||
it('Searched by first/last', async () => { | ||
@@ -117,3 +129,3 @@ var cust = {firstName: 'Helmer', lastName: 'HERRERA BUITRAGO'}; | ||
assert.deepEqual(actual, expected, 'Name search differs'); | ||
}); | ||
}) | ||
it('Searched case insensitive', async () => { | ||
@@ -123,3 +135,3 @@ var cust = {firstName: 'Helmer', lastName: 'herrera buitrago'}; | ||
assert.deepEqual(actual, expected, 'Name search differs'); | ||
}); | ||
}) | ||
it('Searched clean names', async () => { | ||
@@ -129,3 +141,3 @@ var cust = {firstName: 'Helmer', lastName: 'herrera-buitrago'}; | ||
assert.deepEqual(actual, expected, 'Name search differs'); | ||
}); | ||
}) | ||
it('Checked aliases', async () => { | ||
@@ -135,3 +147,3 @@ var cust = {firstName: 'Helmer', lastName: 'pacho'}; | ||
assert.deepEqual(actual, expected, 'Name search differs'); | ||
}); | ||
}) | ||
it('Uses external path', async () => { | ||
@@ -151,3 +163,3 @@ var moved = fn.replace(/xml$/, 'moved.xml') | ||
); | ||
}); | ||
}) | ||
it('No match found', async () => { | ||
@@ -157,4 +169,4 @@ var cust = {firstName: 'XX', lastName: 'XX'}; | ||
assert.deepEqual(actual, [], 'Empty array expected'); | ||
}); | ||
}); | ||
}); | ||
}) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28053
315