<commit_before>
  //==================================================
  //
  //
  //
  //  THOSE TEST ARE **REALLY** IMPORTANT SO IF SOME
  //  OF THEM IS BROKEN, PLEASE, TAKE CARE OF IT
  //
  //  Visualization model specs
  //
  //==================================================

  describe("Visualization model", function() {
    var vis, table, table_server, map_id;

    beforeEach(function() {

      cdb.admin.CartoDBLayer.updateCartoCss = function() {};

      map_id = 96;

      // Visualization model
      vis = new cdb.admin.Visualization({
        map_id:           map_id,
        active_layer_id:  null,
        name:             "test_table",
        description:      "Visualization description",
        tags:             ["jamon","probando","test"],
        privacy:          "PUBLIC",
        updated_at:       "2013-03-04T18:09:34+01:00",
        type:             "table"
      });
    });

    /* defaults & config */
    describe('> defaults & config', function() {

      it("should define a number of ITEMS_PER_PAGE", function() {
        expect(cdb.admin.Visualizations.prototype._ITEMS_PER_PAGE).toBeDefined();
      });

      it("should define a number of PREVIEW_ITEMS_PER_PAGE", function() {
        expect(cdb.admin.Visualizations.prototype._PREVIEW_ITEMS_PER_PAGE).toBeDefined();
      });

      it("should setup map bindings by default", function() {
        expect(vis.get("bindMap")).toBeTruthy();
        expect(vis.map.get("id")).toEqual(map_id);
      });

      it("shouldn't setup map bindings when bindMap is false", function() {

        vis = new cdb.admin.Visualization({
          map_id:  map_id,
          bindMap: false
        });

        expect(vis.get("bindMap")).toBeFalsy();
        expect(vis.map.get("id")).toEqual(null);

      });

    });

    /* map_id specs */
    describe('> map_id', function() {});

    /* isVisualization spec */
    describe('> isVisualization', function() {
      var cartodb_layer;

      beforeEach(function() {
        cartodb_layer = new cdb.admin.CartoDBLayer({ table_name: 'test_table'});

        vis.map.layers.reset([
          new cdb.geo.MapLayer(),
          cartodb_layer
        ]);
      });

      it("should return if the model is a visualization or a table", function() {
        expect(vis.isVisualization()).toBeFalsy();
        vis.set({
          "type": "derived"
        });

        vis.map.layers.reset([<commit_msg>Adds parse/fetch spec to vis.js<commit_after>
  //==================================================
  //
  //
  //
  //  THOSE TEST ARE **REALLY** IMPORTANT SO IF SOME
  //  OF THEM IS BROKEN, PLEASE, TAKE CARE OF IT
  //
  //  Visualization model specs
  //
  //==================================================

  describe("Visualization model", function() {
    var vis, table, table_server, map_id;

    beforeEach(function() {

      cdb.admin.CartoDBLayer.updateCartoCss = function() {};

      map_id = 96;

      // Visualization model
      vis = new cdb.admin.Visualization({
        map_id:           map_id,
        active_layer_id:  null,
        name:             "test_table",
        description:      "Visualization description",
        tags:             ["jamon","probando","test"],
        privacy:          "PUBLIC",
        updated_at:       "2013-03-04T18:09:34+01:00",
        type:             "table"
      });
    });

    /* defaults & config */
    describe('> defaults & config', function() {

      it("should define a number of ITEMS_PER_PAGE", function() {
        expect(cdb.admin.Visualizations.prototype._ITEMS_PER_PAGE).toBeDefined();
      });

      it("should define a number of PREVIEW_ITEMS_PER_PAGE", function() {
        expect(cdb.admin.Visualizations.prototype._PREVIEW_ITEMS_PER_PAGE).toBeDefined();
      });

      it("should setup map bindings by default", function() {
        expect(vis.get("bindMap")).toBeTruthy();
        expect(vis.map.get("id")).toEqual(map_id);
      });

      it("shouldn't setup map bindings when bindMap is false", function() {

        vis = new cdb.admin.Visualization({
          map_id:  map_id,
          bindMap: false
        });

        expect(vis.get("bindMap")).toBeFalsy();
        expect(vis.map.get("id")).toEqual(null);

      });

    });

    /* map_id specs */
    describe('> map_id', function() {

      it("should set bindMap to false for all visualizations on parse/fetch", function() {
        var visualizations = new cdb.admin.Visualizations({ type: "derived" });
        var result;

        visualizations.fetch({ success: function(){
          result = true;
        }})

        waitsFor(function() {
          return result;
        }, 'timeout', 1000);

        runs(function() {
          expect(visualizations.at(0).get("bindMap")).toBeFalsy();
        });

      });

    });

    /* isVisualization spec */
    describe('> isVisualization', function() {
      var cartodb_layer;

      beforeEach(function() {
        cartodb_layer = new cdb.admin.CartoDBLayer({ table_name: 'test_table'});

        vis.map.layers.reset([
          new cdb.geo.MapLayer(),
          cartodb_layer
        ]);
      });

      it("should return if the model is a visualization or a table", function() {
        expect(vis.isVisualization()).toBeFalsy();
        vis.set({
          "type": "derived"
        });

        vis.map.layers.reset([
{'fraction_non_alphanumeric': 0.17485119047619047, 'fraction_numerical': 0.008370535714285714, 'mean_word_length': 2.2197604790419163, 'pattern_counts': {'":': 2, '<': 3, '<?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': '5443276', 'n_tokens_mistral': 1672, 'n_tokens_neox': 1565, 'n_words': 322}