<commit_before>describe("Spark", function() {
  describe("login", function() {

    var subject = function(callback) {
      return Spark.login('spark', 'spark', callback);
    };

    shared.behavesLikeInvalidGrant(subject, 'login');

    describe("with correct params", function() {
      var eventName = 'login',
      data = { access_token: 'access_token' };

      shared.stubRequest(data);
      shared.behavesLikeSuccess('login', subject, data);
    });

    it("sets accessToken correctly", function(){
      subject(function() {
        expect(Spark.accessToken).to.eq('access_token');
      });
    });
  });

  describe("listDevices", function() {

    var subject = function(callback) {
      return Spark.listDevices(callback);
    };

    describe("with correct params", function() {
      var eventName = 'listDevices',
      data = [{name: 'sparky'}];

      shared.stubRequest(data);
      shared.behavesLikeSuccess(eventName, subject, data);
    });

    shared.behavesLikeInvalidGrant(subject, 'listDevices');

    it("sets devices correctly", function(){
      subject(function() {
        expect(Spark.devices).to.eq([{name: 'sparky'}]);
      });
    });
  });

  describe("createUser", function() {

    var subject = function(callback) {
      return Spark.createUser('<EMAIL>', '<PASSWORD>', callback);
    };

    describe("with correct params", function() {
      var eventName = 'createUser',
      data = {ok: true};

      shared.stubRequest(data);
      shared.behavesLikeSuccess(eventName, subject, data);
    });

    shared.behavesLikeInvalidGrant(subject, 'createUser');

    describe('with invalid username', function() {
      it('returns correct error message', function() {
        subject = function(callback) {
          return Spark.createUser('', 'pass', callback);
        };

        shared.behavesLikeError('createUser', subject, 'Username must be an email address.');
      });
    });
  });
});

<commit_msg>removeAccesstoken and claimCore basic tests<commit_after>describe("Spark", function() {
  describe("login", function() {

    var subject = function(callback) {
      return Spark.login('spark', 'spark', callback);
    };

    shared.behavesLikeInvalidGrant(subject, 'login');

    describe("with correct params", function() {
      var eventName = 'login',
      data = { access_token: 'access_token' };

      shared.stubRequest(data);
      shared.behavesLikeSuccess('login', subject, data);
    });

    it("sets accessToken correctly", function(){
      subject(function() {
        expect(Spark.accessToken).to.eq('access_token');
      });
    });
  });

  describe("listDevices", function() {

    var subject = function(callback) {
      return Spark.listDevices(callback);
    };

    describe("with correct params", function() {
      var eventName = 'listDevices',
      data = [{name: 'sparky'}];

      shared.stubRequest(data);
      shared.behavesLikeSuccess(eventName, subject, data);
    });

    shared.behavesLikeInvalidGrant(subject, 'listDevices');

    it("sets devices correctly", function(){
      subject(function() {
        expect(Spark.devices).to.eq([{name: 'sparky'}]);
      });
    });
  });

  describe("createUser", function() {

    var subject = function(callback) {
      return Spark.createUser('<EMAIL>', '<PASSWORD>', callback);
    };

    describe("with correct params", function() {
      var eventName = 'createUser',
      data = {ok: true};

      shared.stubRequest(data);
      shared.behavesLikeSuccess(eventName, subject, data);
    });

    shared.behavesLikeInvalidGrant(subject, 'createUser');

    describe('with invalid username', function() {
      it('returns correct error message', function() {
        subject = function(callback) {
          return Spark.createUser('', 'pass', callback);
        };

        shared.behavesLikeError('createUser', subject, 'Username must be an email address.');
      });
    });
  });

  describe("removeAccessToken", function() {

    var subject = function(callback) {
      return Spark.removeAccessToken('<EMAIL>', 'pass', 'access_token', callback);
    };

    describe("with correct params", function() {
      var eventName = 'removeAccessToken',
      data = {ok: true};

      shared.stubRequest(data);
      shared.behavesLikeSuccess(eventName, subject, data);
    });
  });

  describe("claimCore", function() {

    var subject = function(callback) {
      return Spark.claimCore('core_id', callback);
    };

    describe("with correct params", function() {
      var eventName = 'claimCore',
      data = { access_token: '<PASSWORD>',
        token_type: 'bearer',
        expires_in: 7776000 };


      shared.stubRequest(data);
      shared.behavesLikeSuccess(eventName, subject, data);
    });
  });
});



{'fraction_non_alphanumeric': 0.15581151832460732, 'fraction_numerical': 0.0014659685863874345, 'mean_word_length': 3.1858019281332166, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '4376448', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1319, 'n_words': 276}