<commit_before>(function() {
  ViewTest = TestCase("ViewTest");

  ViewTest.prototype.testSetVariable = function() {
    /*:DOC += <div id = "template"><span class = "variable"></span></div>*/
    var view = new LiveView($("#template").get(0));
    view.update("variable", "value");
    assertEquals("Variable was not set", $("#template .variable").html(), "value");
  };

  ViewTest.prototype.testAddIterable = function() {
    /*:DOC += <div id = "templateIterable">
                <ul class = "things">
                  <li class = "thing">
                    <span class = "variable"></span>
                  </li>
                </ul>
              </div>*/
    var view = new LiveView($("#templateIterable").get(0));

    view.add("thing", {"variable": "value"});
    view.add("thing", {"variable": "value2"});

    assertEquals("Variable was not set", $("#templateIterable li:nth-child(1) .variable").html(), "value");
    assertEquals("Variable was not set", $("#templateIterable li:nth-child(2) .variable").html(), "value2");
  }; 

  ViewTest.prototype.testUpdateIterable = function() {
    /*:DOC += <div id = "templateIterable">
                <ul class = "things">
                  <li class = "thing">
                    <span class = "variable"></span>
                  </li>
                </ul>
              </div>*/
    var view = new LiveView($("#templateIterable").get(0));

    var thing = view.add("thing", {"variable": "value"});
    thing.update({"variable": "newValue"});
    assertEquals("Variable was not set", $("#templateIterable .variable").html(), "newValue");
  }; 

  ViewTest.prototype.testDeleteIterable = function() {
    /*:DOC += <div id = "templateIterable">
                <ul class = "things">
                  <li class = "thing">
                    <span class = "variable"></span>
                  </li>
                </ul>
              </div>*/
    var view = new LiveView($("#templateIterable").get(0));

    var thing = view.add("thing", {"variable": "value"});
    var thing2 = view.add("thing", {"variable": "value2"});

    thing.remove();
    assertEquals("Not deleted", 1, $("#templateIterable .variable").length);
    assertEquals("Deleted wrong thing", $("#templateIterable .variable").html(), "value2");
  }; 

}());<commit_msg>whoa lots of stuff<commit_after>(function() {
  ViewTest = TestCase("ViewTest");

  ViewTest.prototype.testSetVariable = function() {
    /*:DOC += <div id = "template"><span class = "variable"></span></div>*/
    var view = new LiveView($("#template").get(0));
    view.set("variable", "value");
    assertEquals("Variable was not set", $("#template .variable").html(), "value");
  };

  ViewTest.prototype.testSetAttribute = function() {
    /*:DOC += <div id = "template"><a class = "variable"></a></div>*/
    var view = new LiveView($("#template"));
    view.set("variable", {"content":"googs", "href": "http://google.com"});
    assertEquals("Variable was not set", $("#template .variable").attr("href"), "http://google.com");
  }; 

  ViewTest.prototype.testAddIterable = function() {
    /*:DOC += <div id = "templateIterable">
                <ul class = "things">
                  <li class = "thing">
                    <span class = "variable"></span>
                  </li>
                </ul>
              </div>*/
    var template = new LiveView("#templateIterable", {
      "things": [{"variable": "A variable"}]
    });

    template.things.add({"variable": "A value"});

    assertEquals("Variable was not set", $("#templateIterable li:nth-child(1) .variable").html(), "A variable");
    assertEquals("Variable was not set", $("#templateIterable li:nth-child(2) .variable").html(), "A value");
  }; 

  ViewTest.prototype.testUpdateIterable = function() {
    /*:DOC += <div id = "templateCollection">
                <ul class = "things">
                  <li class = "thing">
                    <span class = "variable"></span>
                  </li>
                </ul>
              </div>*/
    var view = new LiveView($("#templateCollection"));

    var thing = view.things.add({"variable": "value"});
    thing.set({"variable": "newValue"});
    assertEquals("Variable was not set", $("#templateIterable .variable").html(), "newValue");
  }; 
  /* FRACK THIS TEST IT WORKS IN THE EXAMPLES WITH THE EXACT SAME CODE */
  ViewTest.prototype.testDeleteIterable = function() {
    /*:DOC += <div id = "templateDelete">
                <ul class = "things">
                  <li class = "thing">
                    <span class = "variable"></span>
                  </li>
                </ul>
              </div>*/
    var template = new LiveView($("#templateDelete"), {
      "things": [{"variable": "A variable"}]
    });

    template.things.remove(0);
    assertEquals("Not deleted", 0, $("#templateDelete .thing .variable").length);
  }; 

  ViewTest.prototype.testGetById = function() {
    /*:DOC += <div id = "templateWitIds">
                <ul class = "things">
                  <li class = "thing">
                    <span class = "variable"></span>
                  </li>
                </ul>
              </div>*/
    var template = new LiveView($("#templateWitIds"), {
      "things": [{"variable": "A variable", "id": "ac23f"}, 
                 {"variable": "Another variable", "id": "5c139"}]
    });

    var item = template.things.getById("ac23f");
    assertEquals("Not deleted", "ac23f", item.data.id);
  }; 
  ViewTest.prototype.testSort = function() {
    /*:DOC += <div id = "templateWitIds">
                <ul class = "things">
                  <li class = "thing">
                    <span class = "variable"></span>
                  </li>
                </ul>
              </div>*/
    var template = new LiveView($("#templateWitIds"), {
      "things": [{"variable": 1}, 
                 {"variable": 10},
                 {"variable": 2},
                 {"variable": 6}]
    });

    template.things.sort(function(data1, data2) {
      return data1.variable - data2.variable;
    });
    fail();
  };       
  ViewTest.prototype.testAddAfterSort = function() {
    /*:DOC += <div id = "templateWitIds">
                <ul class = "things">
                  <li class = "thing">
                    <span class = "variable"></span>
                  </li>
                </ul>
              </div>*/
    var template = new LiveView($("#templateWitIds"), {
      "things": [{"variable": 1}, 
                 {"variable": 10},
                 {"variable": 2},
                 {"variable": 6}]
    });

    template.things.sort(function(data1, data2) {
      return data1.variable - data2.variable;
    });
  }; 
}());

{'fraction_non_alphanumeric': 0.19083855565502836, 'fraction_numerical': 0.006714413607878245, 'mean_word_length': 2.110440835266821, 'pattern_counts': {'":': 30, '<': 87, '<?xml version=': 0, '>': 87, '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': '6673076', 'n_tokens_mistral': 1971, 'n_tokens_neox': 1832, 'n_words': 439}