<commit_before>var sga = require("__buttercup/classes/commands/command.sga.js");

module.exports = {
  setUp: function(cb) {
    this.command = new sga();
    (cb)();
  },

  errors: {
    groupNotFoundForId: function(test) {
      var fakeSearching = {
        findGroupByID: function(a, b) {
          return false;
        }
      };

      this.command.injectSearching(fakeSearching);

      var errorThrown = false;
      try {
        this.command.execute({ }, 0, '', '');
      } catch (e) {
        if (e.message === 'Group not found for ID') {
          errorThrown = true;
        }
      } finally {
        test.strictEqual(errorThrown, true, 'Error thrown');
        test.done();
      }
    }
  },

  setAttribute: {
    setsAttributeValueValForNameNam: function(test) {
      var attributeName = 'Nam',
          attributeValue = 'Val';

      var fakeGroup = {
        attributes: {}
      };

      var fakeSearching = {
        findGroupByID: function(a, b) {
          return fakeGroup;
        }
      };

      this.command.injectSearching(fakeSearching);

      this.command.execute({ }, 0, attributeName, attributeValue);

      test.strictEqual(fakeGroup.attributes[attributeName], attributeValue, 'Attribute value is correctly set. ([' + attributeName + '] = ' + attributeValue + ')');
      test.done();
    },

    setsAttributeValueFooForNameBar: function(test) {
      var attributeName = 'Bar',
          attributeValue = 'Foo';

      var fakeGroup = {
        attributes: {}
      };

      var fakeSearching = {
        findGroupByID: function(a, b) {
          return fakeGroup;
        }
      };

      this.command.injectSearching(fakeSearching);

      this.command.execute({ }, 0, attributeName, attributeValue);

      test.strictEqual(fakeGroup.attributes[attributeName], attributeValue, 'Attribute value is correctly set. ([' + attributeName + '] = ' + attributeValue + ')');
      test.done();
    }
  }
};<commit_msg>Set up fakeGroup before tests<commit_after>var sga = require("__buttercup/classes/commands/command.sga.js");

var fakeGroup;

module.exports = {
  setUp: function(cb) {
    this.command = new sga();
    (cb)();
  },

  errors: {
    groupNotFoundForId: function(test) {
      var fakeSearching = {
        findGroupByID: function(a, b) {
          return false;
        }
      };

      this.command.injectSearching(fakeSearching);

      var errorThrown = false;
      try {
        this.command.execute({ }, 0, '', '');
      } catch (e) {
        if (e.message === 'Group not found for ID') {
          errorThrown = true;
        }
      } finally {
        test.strictEqual(errorThrown, true, 'Error thrown');
        test.done();
      }
    }
  },

  setAttribute: {
    setUp: function(cb) {
      fakeGroup = {
        attributes: {}
      };

      (cb)();
    },

    setsAttributeValueValForNameNam: function(test) {
      var attributeName = 'Nam',
          attributeValue = 'Val';

      var fakeSearching = {
        findGroupByID: function(a, b) {
          return fakeGroup;
        }
      };

      this.command.injectSearching(fakeSearching);

      this.command.execute({ }, 0, attributeName, attributeValue);

      test.strictEqual(fakeGroup.attributes[attributeName], attributeValue, 'Attribute value is correctly set. ([' + attributeName + '] = ' + attributeValue + ')');
      test.done();
    },

    setsAttributeValueFooForNameBar: function(test) {
      var attributeName = 'Bar',
          attributeValue = 'Foo';

      var fakeSearching = {
        findGroupByID: function(a, b) {
          return fakeGroup;
        }
      };

      this.command.injectSearching(fakeSearching);

      this.command.execute({ }, 0, attributeName, attributeValue);

      test.strictEqual(fakeGroup.attributes[attributeName], attributeValue, 'Attribute value is correctly set. ([' + attributeName + '] = ' + attributeValue + ')');
      test.done();
    }
  }
};
{'fraction_non_alphanumeric': 0.1342298908906369, 'fraction_numerical': 0.0015224562293834052, 'mean_word_length': 2.309823677581864, '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': '1850023', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1146, 'n_words': 223}