<commit_before>describe('Osteo.Collection', function() {
  describe('#model', function() {
    it('defautlts the model to Osteo.Model', function() {
      var collection = new Osteo.Collection();

      expect(collection.model).to.eql(Osteo.Model);
    });
  });

  describe('#parse', function() {
    it('extracts data from the root key', function() {
      var collection = new Osteo.Collection([], { root: 'posts' }),
          payload    = { posts: [{ id: 1 }, { id: 2 }] };

      expect(collection.parse(payload).length).to.eq(2);
    });

    it('falls back to the response without a root', function() {
      var collection = new Osteo.Collection([], { root: 'posts' }),
          payload = [{ id: 1 }, { id: 2 }];

      expect(collection.parse(payload)).to.eql(payload);
    });
  });

  describe('#set', function() {
    it('correctly merges models with a root', function() {
      var payload    = [{ id: 1, name: 'a' }, { id: 2, name: 'b' }],
          collection = new Osteo.Collection(payload, { root: 'posts' });

      collection.set({ posts: [
        { id: 1, name: 'z' }, { id: 3, name: 'y' }
      ]}, { remove: false });

      expect(collection.pluck('name')).to.eql(['z', 'b', 'y'])
    });
  });

  describe('#create', function() {
    it('passes the root through to new models', function() {
      var coll = new Osteo.Collection([], { root: 'posts' });

      var model = coll.create({ id: 1 });

      expect(model.root).to.eq('post')
    });
  });

  describe('#toJSON', function() {
    it('flattens model attributes', function() {
      var models = [{ id: 1 }, { id: 2 }],
          collection = new Osteo.Collection(models, { root: 'posts' });

      expect(collection.toJSON()).to.eql(models);
    });

    it('flattens models into the root namespace', function() {
      var models = [{ id: 1 }, { id: 2 }],
          collection = new Osteo.Collection(models, { root: 'posts' });

      expect(collection.toJSON({ rooted: true })).to.eql({ posts: models });
    });
  });

  describe('.root', function() {
    it('passes root options through to models', function() {
      var collection = new Osteo.Collection([], { root: 'posts' }),
          models = collection.set({ posts: [{ id: 2 }, { id: 3 }]}, { parse: true });<commit_msg>Use dummy model to prevent url save error<commit_after>describe('Osteo.Collection', function() {
  describe('#model', function() {
    it('defautlts the model to Osteo.Model', function() {
      var collection = new Osteo.Collection();

      expect(collection.model).to.eql(Osteo.Model);
    });
  });

  describe('#parse', function() {
    it('extracts data from the root key', function() {
      var collection = new Osteo.Collection([], { root: 'posts' }),
          payload    = { posts: [{ id: 1 }, { id: 2 }] };

      expect(collection.parse(payload).length).to.eq(2);
    });

    it('falls back to the response without a root', function() {
      var collection = new Osteo.Collection([], { root: 'posts' }),
          payload = [{ id: 1 }, { id: 2 }];

      expect(collection.parse(payload)).to.eql(payload);
    });
  });

  describe('#set', function() {
    it('correctly merges models with a root', function() {
      var payload    = [{ id: 1, name: 'a' }, { id: 2, name: 'b' }],
          collection = new Osteo.Collection(payload, { root: 'posts' });

      collection.set({ posts: [
        { id: 1, name: 'z' }, { id: 3, name: 'y' }
      ]}, { remove: false });

      expect(collection.pluck('name')).to.eql(['z', 'b', 'y'])
    });
  });

  describe('#create', function() {
    var LocalModel = Osteo.Model.extend({
      save: function() { return true; }
    });

    it('passes the root through to new models', function() {
      var coll = new Osteo.Collection([], {
        model: LocalModel,
        root: 'posts'
      });

      var model = coll.create({ id: 1 });

      expect(model.root).to.eq('post')
    });
  });

  describe('#toJSON', function() {
    it('flattens model attributes', function() {
      var models = [{ id: 1 }, { id: 2 }],
          collection = new Osteo.Collection(models, { root: 'posts' });

      expect(collection.toJSON()).to.eql(models);
    });

    it('flattens models into the root namespace', function() {
      var models = [{ id: 1 }, { id: 2 }],
          collection = new Osteo.Collection(models, { root: 'posts' });

      expect(collection.toJSON({ rooted: true })).to.eql({ posts: models });
    });
  });

  describe('.root', function() {
    it('passes root options through to models', function() {
      var collection = new Osteo.Collection([], { root: 'posts' }),
          models = collection.set({ posts: [{ id: 2 }, { id: 3 }]}, { parse: true });
{'fraction_non_alphanumeric': 0.19556881124840222, 'fraction_numerical': 0.006817213463996591, 'mean_word_length': 2.756, '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': '5660293', 'n_tokens_mistral': 1510, 'n_tokens_neox': 1431, 'n_words': 386}