<commit_before>/*
Name:         skyhook-api test script
Description:  Test script for skyhook-api node.js module
Author:       <NAME> (https://frankl.in)
Source:       https://github.com/fvdm/nodejs-skyhook
Feedback:     https://github.com/fvdm/nodejs-skyhook/issues
License       Unlicense (Public Domain)
              See https://github.com/fvdm/nodejs-skyhook/raw/master/LICENSE
*/

var dotest = require ('dotest');
var app = require ('./');

// Setup
// set env SKYHOOK_USER SKYHOOK_KEY (Travis CI)
// or use cli arguments: npm test --skyhookUser=<EMAIL> --skyhookKey=abc123
var user = process.env.SKYHOOK_USER || null;
var key = process.env.SKYHOOK_KEY || null;
var timeout = process.env.SKYHOOK_TIMEOUT || 5000;

var skyhook = app && app (user, key, timeout);


// invalid
dotest.add ('Error: api error', function (test) {
  skyhook ('invalid input', function (err, data) {
    test ()
      .isError ('fail', 'err', err)
      .isExactly ('fail', 'err.message', err && err.message, 'api error')
      .isExactly ('warn', 'err.code', err && err.code, 400)
      .isExactly ('warn', 'err.test', err && err.text, 'malformed ip')
      .isUndefined ('fail', 'data', data)
      .done ();
  });
});

// T-Mobile NL IP
dotest.add ('good ip', function (test) {
  skyhook ('172.16.31.10', function (err, data) {
    var location = data && data.location;
    var civic = data && data.civic;

    test (err)
      .isObject ('fail', 'data', data)
      .isObject ('fail', 'data.location', location)
      .isNumber ('fail', 'data.location.latitude', location && location.latitude)
      .isNumber ('fail', 'data.location.hpe', location && location.hpe)
      .isExactly ('fail', 'data.ip', data && data.ip, '172.16.31.10')
      .isObject ('fail', 'data.civic', civic)
      .isExactly ('fail', 'data.civic.countryIso', civic && civic.countryIso, 'NL')
      .done ();
  });
});

dotest.run ();<commit_msg>Test: minor comment<commit_after>/*
Name:         skyhook-api test script
Description:  Test script for skyhook-api node.js module
Author:       <NAME> (https://frankl.in)
Source:       https://github.com/fvdm/nodejs-skyhook
Feedback:     https://github.com/fvdm/nodejs-skyhook/issues
License       Unlicense (Public Domain)
              See https://github.com/fvdm/nodejs-skyhook/raw/master/LICENSE
*/

var dotest = require ('dotest');
var app = require ('./');

// Setup
// set env SKYHOOK_USER SKYHOOK_KEY (Travis CI)
// or use cli arguments: npm test --skyhookUser=your<EMAIL>ld --skyhookKey=abc123
var user = process.env.SKYHOOK_USER || null;
var key = process.env.SKYHOOK_KEY || null;
var timeout = process.env.SKYHOOK_TIMEOUT || 5000;

var skyhook = app && app (user, key, timeout);


// invalid
dotest.add ('Error: api error', function (test) {
  skyhook ('invalid input', function (err, data) {
    test ()
      .isError ('fail', 'err', err)
      .isExactly ('fail', 'err.message', err && err.message, 'api error')
      .isExactly ('warn', 'err.code', err && err.code, 400)
      .isExactly ('warn', 'err.test', err && err.text, 'malformed ip')
      .isUndefined ('fail', 'data', data)
      .done ();
  });
});

// T-Mobile NL IP
dotest.add ('good ip', function (test) {
  skyhook ('172.16.31.10', function (err, data) {
    var location = data && data.location;
    var civic = data && data.civic;

    test (err)
      .isObject ('fail', 'data', data)
      .isObject ('fail', 'data.location', location)
      .isNumber ('fail', 'data.location.latitude', location && location.latitude)
      .isNumber ('fail', 'data.location.hpe', location && location.hpe)
      .isExactly ('fail', 'data.ip', data && data.ip, '172.16.31.10')
      .isObject ('fail', 'data.civic', civic)
      .isExactly ('fail', 'data.civic.countryIso', civic && civic.countryIso, 'NL')
      .done ();
  });
});

// Run tests
dotest.run ();
{'fraction_non_alphanumeric': 0.1797547612835899, 'fraction_numerical': 0.014609966084007305, 'mean_word_length': 3.0874200426439233, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '839066', 'n_tokens_mistral': 1366, 'n_tokens_neox': 1299, 'n_words': 340}