<commit_before>"use strict";
var should = require("should");
var Collection = require("../dist/Collection").Collection;
var _ = require("underscore");

describe("Collection", function() {
  // test data
  let objs = [{
      "id": 1,
      "hello": "world"
    }, {
      "id": 2,
      "hello": "something"
    }],
    collection;

  beforeEach(function() {
    collection = new Collection();
  });

  describe("constructor", function() {

    it("should take js objects as arguments when creating a new collection", function() {
      let col = new Collection(objs);
      col.length.should.equal(2);
    });
  });

  describe("add", function() {

    it("should add js objects as models to the collection", function() {
      collection.add(objs);
      collection.length.should.equal(2);
      collection.get(1).get("hello").should.equal("world");
      collection.get(2).get("hello").should.equal("something");
    });
  });

  describe("toJSON", function() {

    it("should return js objects of all the containing models", function() {
      collection.add(objs);
      let jsObjs = collection.toJSON();
      _.isEqual(jsObjs, objs).should.be.true;
    });

    it("should return sorter array of js objects when a comparator is added to the collection", function() {
      function SortedCollection(objs) {
        Collection.call(this, objs);
      };
      SortedCollection.prototype = Object.create(Collection.prototype);
      SortedCollection.prototype.comparator = function(modelA, modelB) {
        return modelA.get("hello").localeCompare(modelB.get("hello"));
      };
      SortedCollection.prototype.constructor = SortedCollection;
      let col = new SortedCollection(objs),
        jsObjs = col.toJSON();
      jsObjs[0].hello.should.equal("something");
      jsObjs[1].hello.should.equal("world");
    });

  });

});<commit_msg>cleaned up the descriptions, now the spec reported seems to give more reasonable results<commit_after>"use strict";
var should = require("should");
var Collection = require("../dist/Collection").Collection;
var _ = require("underscore");

describe("Collection", function() {
  // test data
  let objs = [{
      "id": 1,
      "hello": "world"
    }, {
      "id": 2,
      "hello": "something"
    }],
    collection;

  beforeEach(function() {
    collection = new Collection();
  });

  describe("constructor", function() {

    it("should take js objects as arguments when creating a new collection", function() {
      let col = new Collection(objs);
      col.length.should.equal(2);
    });
  });

  describe("add", function() {

    it("should add js objects as models to the collection", function() {
      collection.add(objs);
      collection.length.should.equal(2);
      collection.get(1).get("hello").should.equal("world");
      collection.get(2).get("hello").should.equal("something");
    });
  });

  describe("toJSON", function() {

    it("should return js objects of all the containing models", function() {
      collection.add(objs);
      let jsObjs = collection.toJSON();
      _.isEqual(jsObjs, objs).should.be.true;
    });
  });

  describe("comparator", function() {
    
    function SortedCollection(objs) {
      Collection.call(this, objs);
    };
    SortedCollection.prototype = Object.create(Collection.prototype);
    SortedCollection.prototype.comparator = function(modelA, modelB) {
      return modelA.get("hello").localeCompare(modelB.get("hello"));
    };
    SortedCollection.prototype.constructor = SortedCollection;

    it("should sort the returned js objects when added to a collection", function() {
      let col = new SortedCollection(objs),
        jsObjs = col.toJSON();
      jsObjs[0].hello.should.equal("something");
      jsObjs[1].hello.should.equal("world");
    });
  });
});
{'fraction_non_alphanumeric': 0.1561014263074485, 'fraction_numerical': 0.004226096143687269, 'mean_word_length': 3.2839366515837103, 'pattern_counts': {'":': 8, '<': 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': '6094334', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1077, 'n_words': 249}