<commit_before>global.XMLHttpRequest = require('xhr2');
global.dataLayer = [];
var test = require('blue-tape');
var GeordiClient = require('../index');

test('Instantiate a client with default settings', function(t) {
  var geordi = new GeordiClient();
  t.equal(geordi.env, 'staging');
  t.equal(geordi.projectToken, 'unspecified');
  t.end();
});
test('Instantiate a client with older settings', function(t) {
  var geordi = new GeordiClient({server: 'production'});
  t.equal(geordi.env, 'production');
  t.end();
});
test('Log without a valid project token', function(t) {
  var geordi = new GeordiClient({projectToken:''});
  geordi.logEvent('test event')
    .then(function(response){
      t.fail('invalid project token should not be logged');
      t.end();
    })
    .catch(function(error){
      t.pass(error);
      t.end();
    });
});
test('Log with valid project token', function(t) {
  var geordi = new GeordiClient({projectToken: 'test/token'});
  geordi.logEvent('test event')
    .then(function(response){
      t.pass('Valid project token will allow logging');
      t.end();
    })
});
test('Update data on Geordi', function(t) {
  var geordi = new GeordiClient({projectToken: 'test/token'});
  geordi.update({projectToken: 'new/token'})
  t.equal(geordi.projectToken, 'new/token');
  t.end();
});<commit_msg>Update the log test to check the event data<commit_after>global.XMLHttpRequest = require('xhr2');
global.dataLayer = [];
var test = require('blue-tape');
var GeordiClient = require('../index');

test('Instantiate a client with default settings', function(t) {
  var geordi = new GeordiClient();
  t.equal(geordi.env, 'staging');
  t.equal(geordi.projectToken, 'unspecified');
  t.end();
});
test('Instantiate a client with older settings', function(t) {
  var geordi = new GeordiClient({server: 'production'});
  t.equal(geordi.env, 'production');
  t.end();
});
test('Log without a valid project token', function(t) {
  var geordi = new GeordiClient({projectToken:''});
  geordi.logEvent('test event')
    .then(function(response){
      t.fail('invalid project token should not be logged');
      t.end();
    })
    .catch(function(error){
      t.pass(error);
      t.end();
    });
});
test('Log with valid project token', function(t) {
  var geordi = new GeordiClient({projectToken: 'test/token'});
  geordi.logEvent('test event')
    .then(function(data){
      return JSON.parse(data);
    })
    .then(function(event){
      t.equal(event.projectToken, 'test/token', "correct project token");
      t.equal(event.type, 'test event', "correct event type");
      t.end();
    })
});
test('Update data on Geordi', function(t) {
  var geordi = new GeordiClient({projectToken: 'test/token'});
  geordi.update({projectToken: 'new/token'})
  t.equal(geordi.projectToken, 'new/token');
  t.end();
});
{'fraction_non_alphanumeric': 0.1772598870056497, 'fraction_numerical': 0.0007062146892655367, 'mean_word_length': 4.265799256505576, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '2586537', 'n_tokens_mistral': 953, 'n_tokens_neox': 950, 'n_words': 218}