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('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()
});

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();
});

Test that server config hasn't broken
Test that server config hasn't broken
