<commit_before>/*jshint -W117 */

var store, adapter, serializer;

var postsPayload = [{
  title: "<NAME>",
  comments: {
    "comment_1": true,
    "comment_2": true
  }
},{
  title: "<NAME>",
  comments: {
    "comment_1": true,
    "comment_2": true
  }
}];

module("FirebaseSerializer", {
  setup: function() {
    App.reset();
    store = App.__container__.lookup('store:main');
    serializer = App.__container__.lookup('serializer:application');
  }
});

  test("#normalize()", function() {

    ok(typeof DS.FirebaseSerializer !== 'undefined');

    test("Valid payload", function() {
      var postPayload = {
        title: "<NAME>",
        comments: {
          "comment_1": true,
          "comment_2": true
        }
      };
      var normalizedPayload = serializer.normalize(store.modelFor('post'), postPayload);

      ok(Ember.isArray(normalizedPayload.comments), "it converts hasMany relationships to arrays");
    });

    test("Invalid payload", function() {
      var postPayload = {
        title: "<NAME>",
        comments: ["comment_1", "comment_2"]
      };

      throws(function() {
        var normalizedPayload = serializer.normalize(store.modelFor('post'), postPayload);
      }, "it throws an error for hasMany relationships that come down as an array");
    });

  });

  test("#extractSingle()", function() {

    var postsPayload = [{
      title: "<NAME>",
      comments: {
        "comment_1": true,
        "comment_2": true
      }
    },{
      title: "<NAME>",
      comments: {
        "comment_1": true,
        "comment_2": true
      }
    }];

    var spy = sinon.spy(serializer, 'extractSingle');
    var extractedArray = serializer.extractArray(store, store.modelFor('post'), postsPayload);

    equal(spy.callCount, 2, "it was called for each item in the payload");

    spy.restore();

  });

  test("#extractArray()", function() {

    var postsPayload = [{
      title: "<NAME>",
      comments: {
        "comment_1": true,
        "comment_2": true
      }
    },{
      title: "<NAME>",
      comments: {
        "comment_1": true,
        "comment_2": true
      }
    }];

    var spy = sinon.spy(serializer, 'extractArray');
    var extractedArray = serializer.extractArray(store, store.modelFor('post'), postsPayload);

    ok(Ember.isArray(extractedArray), "it returns an array");
    equal(spy.callCount, 1, "it was called once");
    equal(extractedArray.length, 2, "the returned array contains the correct amount of items");

    spy.restore();

  });

/*test("root lists first page of posts", function() {
  visit("/posts");
  andThen(function() {
    equal(find(".post-slug").length, 2, "The first page should have 1 post");
  });
});*/<commit_msg>Removed unused object<commit_after>/*jshint -W117 */

var store, adapter, serializer;

module("FirebaseSerializer", {
  setup: function() {
    App.reset();
    store = App.__container__.lookup('store:main');
    serializer = App.__container__.lookup('serializer:application');
  }
});

  test("#normalize()", function() {

    ok(typeof DS.FirebaseSerializer !== 'undefined');

    test("Valid payload", function() {
      var postPayload = {
        title: "<NAME>",
        comments: {
          "comment_1": true,
          "comment_2": true
        }
      };
      var normalizedPayload = serializer.normalize(store.modelFor('post'), postPayload);

      ok(Ember.isArray(normalizedPayload.comments), "it converts hasMany relationships to arrays");
    });

    test("Invalid payload", function() {
      var postPayload = {
        title: "<NAME>",
        comments: ["comment_1", "comment_2"]
      };

      throws(function() {
        var normalizedPayload = serializer.normalize(store.modelFor('post'), postPayload);
      }, "it throws an error for hasMany relationships that come down as an array");
    });

  });

  test("#extractSingle()", function() {

    var postsPayload = [{
      title: "<NAME>",
      comments: {
        "comment_1": true,
        "comment_2": true
      }
    },{
      title: "<NAME>",
      comments: {
        "comment_1": true,
        "comment_2": true
      }
    }];

    var spy = sinon.spy(serializer, 'extractSingle');
    var extractedArray = serializer.extractArray(store, store.modelFor('post'), postsPayload);

    equal(spy.callCount, 2, "it was called for each item in the payload");

    spy.restore();

  });

  test("#extractArray()", function() {

    var postsPayload = [{
      title: "<NAME>",
      comments: {
        "comment_1": true,
        "comment_2": true
      }
    },{
      title: "<NAME>",
      comments: {
        "comment_1": true,
        "comment_2": true
      }
    }];

    var spy = sinon.spy(serializer, 'extractArray');
    var extractedArray = serializer.extractArray(store, store.modelFor('post'), postsPayload);

    ok(Ember.isArray(extractedArray), "it returns an array");
    equal(spy.callCount, 1, "it was called once");
    equal(extractedArray.length, 2, "the returned array contains the correct amount of items");

    spy.restore();

  });

/*test("root lists first page of posts", function() {
  visit("/posts");
  andThen(function() {
    equal(find(".post-slug").length, 2, "The first page should have 1 post");
  });
});*/
{'fraction_non_alphanumeric': 0.1596414266641236, 'fraction_numerical': 0.008392141903490368, 'mean_word_length': 2.816593886462882, 'pattern_counts': {'":': 24, '<': 17, '<?xml version=': 0, '>': 17, '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': '7005113', 'n_tokens_mistral': 1588, 'n_tokens_neox': 1539, 'n_words': 372}