describe("Keen Client", function() {

  beforeEach(function() {
    this.keen = new Keen({
      projectId: keenHelper.projectId,
      readKey: keenHelper.readKey,
      writeKey: keenHelper.writeKey
    });
  });

  describe("constructor", function() {

    it("should create a new Keen instance", function(){
      expect(this.keen).to.be.an.instanceof(Keen);
    });

    it("should error if no configuration object", function() {
      expect(function() {
        (keen = new Keen());
      }).to.throw(Error);
    });

    it("should create a new client object", function(){
      expect(this.keen.client).to.be.ok;
    });

    describe("validates projectId", function(){

      it("should error if projectId is absent", function() {

        expect(function() {
          (keen = new Keen());
        }).to.throw(Error);

      });

      it("should error if projectId is empty", function() {

        expect(function() {
          (keen = new Keen({projectId:''}));
        }).to.throw(Error);

      });

      it("should error if projectId is of incorrect type", function() {

        // Number
        expect(function() {
          (keen = new Keen({projectId:0}));
        }).to.throw(Error);

        // Boolean
        expect(function() {
          (keen = new Keen({projectId:false}));
        }).to.throw(Error);

        // Array
        expect(function() {
          (keen = new Keen({projectId:['array']}));
        }).to.throw(Error);

        // Object
        expect(function() {
          (keen = new Keen({projectId:{}}));
        }).to.throw(Error);

      });

      it("should set the projectId (string)", function() {

        expect(this.keen.client)
          .to.have.property('projectId')
          .that.is.a('string')
          .that.equals(keenHelper.projectId);

      });

    });

    describe("validates readKey", function(){

      it("should set the readKey (string)", function() {
        expect(this.keen.client)
          .to.have.property('readKey')
          .that.is.a('string')
          .that.equals(keenHelper.readKey);

      });

    });

    describe("validates readKey", function(){

      it("should set the writeKey (string)", function() {
        expect(this.keen.client)
          .to.have.property('writeKey')
          .that.is.a('string')
          .that.equals(keenHelper.writeKey);

      });

    });

    describe("validates endpoint", function(){

      it("should default to \"https\" if protocol is absent or of incorrect type", function(){

        // Empty
        var keen_empty = new Keen({ projectId: '123', protocol: '' });
        expect(keen_empty.client.endpoint.indexOf('https://')).to.equal(0);

        // Number
        var keen_number = new Keen({ projectId: '123', protocol: 0 });
        expect(keen_number.client.endpoint.indexOf('https://')).to.equal(0);

        // Boolean
        var keen_boolean = new Keen({ projectId: '123', protocol: true });
        expect(keen_boolean.client.endpoint.indexOf('https://')).to.equal(0);

        // Array
        var keen_array = new Keen({ projectId: '123', protocol: [] });
        expect(keen_array.client.endpoint.indexOf('https://')).to.equal(0);

        // Object
        var keen_object = new Keen({ projectId: '123', protocol: {} });
        expect(keen_object.client.endpoint.indexOf('https://')).to.equal(0);

      });

      it("should set protocol to \"https\" if designated", function(){

        var keen = new Keen({ projectId: '123', protocol: 'https' });
        expect(keen.client.endpoint.indexOf('https://')).to.equal(0);

      });

      it("should set protocol to \"http\" if designated", function(){

        var keen = new Keen({ projectId: '123', protocol: 'http' });
        expect(keen.client.endpoint.indexOf('http://')).to.equal(0);

      });

    });

    describe("validates request type", function(){

      it("should set request type to \"jsonp\" by default", function(){

        var keen = new Keen({ projectId: '123' });
        expect(keen.client)
          .to.have.property('requestType')
          .that.is.a('string')
          .that.equals('jsonp');

        /*if ('withCredentials' in new XMLHttpRequest()) {
          expect(keen.client)
            .to.have.property('requestType')
            .that.is.a('string')
            .that.equals('xhr');
        } else {
          expect(keen.client)
            .to.have.property('requestType')
            .that.is.a('string')
            .that.equals('jsonp');
        }*/

      });

      it("should set request type to \"xhr\" if designated and CORS supported, otherwise fall back \"JSONP\"", function(){

        var keen = new Keen({ projectId: '123', requestType: 'xhr' });
        if ('withCredentials' in new XMLHttpRequest()) {
          expect(keen.client)
            .to.have.property('requestType')
            .that.is.a('string')
            .that.equals('xhr');
        } else {
          expect(keen.client)
            .to.have.property('requestType')
            .that.is.a('string')
            .that.equals('jsonp');
        }

      });

      it("should set request type to \"jsonp\" if designated", function(){

        var keen = new Keen({ projectId: '123', requestType: 'jsonp' });
        expect(keen.client)
          .to.have.property('requestType')
          .that.is.a('string')
          .that.equals('jsonp');

      });

      it("should set request type to \"beacon\" if designated", function(){

        var keen = new Keen({ projectId: '123', requestType: 'beacon' });
        expect(keen.client)
          .to.have.property('requestType')
          .that.is.a('string')
          .that.equals('beacon');

      });

    });

  });
});

@@ -5688,12 +5688,371 @@
 %0A%0A  %7D);%0A
+%0A  describe(%22Keen.urlMaxLength threshold%22, function()%7B%0A    it(%22should be 2000 for IE, and 16000 otherwise%22, function()%7B%0A      if (navigator.userAgent.indexOf('MSIE') !== -1 %7C%7C navigator.appVersion.indexOf('Trident/') %3E 0) %7B%0A        expect(Keen.urlMaxLength).to.eql(2000);%0A      %7D else %7B%0A        expect(Keen.urlMaxLength).to.eql(16000);%0A      %7D%0A    %7D);%0A  %7D);%0A%0A
 %7D);%0A

Add test case for IE/Non theshold switch