fix tests

This commit is contained in:
Moos 2018-10-14 22:50:12 -07:00
parent 31422eafcf
commit 39fba2e7f0
4 changed files with 21 additions and 9 deletions

View File

@ -172,8 +172,6 @@ function is(pos){
* Credit for this routine to https://github.com/NaturalNode/natural
*/
function lineDataToJSON(line, location) {
// if (!dataCheck(line, location)) return new Error('Bad data at location ' + location);
var data = line.split('| '),
tokens = data[0].split(/\s+/),
ptrs = [],

View File

@ -52,11 +52,9 @@ function readLocation(location, callback) {
return;
}
//console.log(' read %d bytes at <%d>', count, location);
if (!dataCheck(str, location)) return callback(new Error('Bad data at location ' + location));
callback(null, function() {
if (!dataCheck(str, location)) return new Error('Bad data at location ' + location);
lineDataToJSON(str, location)
});
callback(null, lineDataToJSON(str, location));
});
function readChunk(pos, cb) {

16
src/wordpos.js Normal file
View File

@ -0,0 +1,16 @@
/*!
* wordpos.js
*
* Node.js part-of-speech utilities using WordNet database.
*
* Copyright (c) 2012-2019 mooster@42at.com
* https://github.com/moos/wordpos
*
* Released under MIT license
*/
if (process.browser) {
module.exports = require('./browser');
} else {
module.exports = require('./node');
}

View File

@ -372,7 +372,7 @@ describe('seek()...', function() {
it('should handle bad offset', function(done) {
wordpos.seek('foobar', 'a', function(err, result){
assert(err instanceof Error);
assert.equal(err.message, 'offset must be valid positive number.');
assert.equal(err.message, 'Offset must be valid positive number: foobar');
done();
}).catch(_.noop); // UnhandledPromiseRejectionWarning
});
@ -498,7 +498,7 @@ describe('Promise pattern', function() {
it('seek() - bad offset', function () {
return wordpos.seek('foobar', 'a').catch(function (err) {
assert(err instanceof Error);
assert.equal(err.message, 'offset must be valid positive number.');
assert.equal(err.message, 'Offset must be valid positive number: foobar');
});
});