<commit_before>(function(window) {
"use strict";

/* 
 * Test Module: Configure
 * Ensures that configuration settings have correct defaults, initialization,
 * overriding, and functionality.
 *
 */
QUnit.module("configure", {
  setup: function() {
    // Backbone.Layout constructor.
    this.Layout = Backbone.Layout;

    // Normal Backbone.View.
    this.View = Backbone.View.extend({
      initialize: function(options) {
        // Set up this View with Layout.
        Backbone.Layout.setupView(this, options);
      }
    });

    // Save a copy of console.warn.
    this.warn = window.console.warn;
  },

  teardown: function() {
    // Ensure the prefix object is restored correctly.
    this.Layout.prototype.options.prefix = "";

    // Remove `manage: true`.
    delete this.Layout.prototype.options.manage;
    delete Backbone.View.prototype.manage;

    // Remove `serialize` option.
    delete this.Layout.prototype.options.serialize;
    delete Backbone.View.prototype.serialize;

    // Remove `el: false`.
    delete this.Layout.prototype.options.el;
    delete Backbone.View.prototype.el;

    // Remove `supressWarnings: true`.
    delete this.Layout.prototype.options.suppressWarnings;
    delete Backbone.View.prototype.suppressWarnings;

    // Not necessary for our testing purposes.
    window.console.trace = function() {};

    // Restore console.warn.
    window.console.warn = this.warn;
    delete this.warn;
  }
});

// Ensure the correct defaults are set for all Layout and View options.
test("defaults", 18, function() {
  // Create a new Layout to test.
  var layout = new this.Layout();
  // Create a new Layout to test.
  var view = new this.View();

  // Paths should be an empty object.
  deepEqual(layout.options.prefix, "", "Layout: No prefix");
  // The deferred property should be a function.
  ok(_.isFunction(layout.options.deferred), "Layout: deferred is a function");
  // The fetch property should be a function.
  ok(_.isFunction(layout.options.fetch), "Layout: fetch is a function");
  // The partial property should be a function.
  ok(_.isFunction(layout.options.partial), "Layout: partial is a function");
  // The html property should be a function.
  ok(_.isFunction(layout.options.html), "Layout: html is a function");
  // The insert property should be a function.
  ok(_.isFunction(layout.options.insert), "Layout: insert is a function");
  // The append property should be a function.
  ok(_.isFunction(layout.options.insert), "Layout: append is a function");
  // The when property should be a function.
  ok(_.isFunction(layout.options.when), "Layout: when is a function");
  // The render property should be a function.
  ok(_.isFunction(layout.options.render), "Layout: render is a function");
  // Paths should be an empty object.
  deepEqual(view.options.prefix, "", "View: No prefix");
  // The deferred property should be a function.
  ok(_.isFunction(view.options.deferred), "View: deferred is a function");
  // The fetch property should be a function.
  ok(_.isFunction(view.options.fetch), "View: fetch is a function");
  // The partial property should be a function.
  ok(_.isFunction(view.options.partial), "View: partial is a function");
  // The html property should be a function.
  ok(_.isFunction(view.options.html), "View: html is a function");
  // The insert property should be a function.
  ok(_.isFunction(view.options.insert), "View: insert is a function");
  // The append property should be a function.
  ok(_.isFunction(view.options.insert), "View: append is a function");
  // The when property should be a function.
  ok(_.isFunction(view.options.when), "View: when is a function");
  // The render property should be a function.
  ok(_.isFunction(view.options.render), "View: render is a function");
});

// Do not allow invalid option assignments to go through.
test("invalid", 2, function() {
  // Configure an invalid property.
  Backbone.Layout.configure("key", "val");

  // Create a new Layout to test.
  var layout = new this.Layout();
  // Create a new View to test.
  var view = new this.View();

  // The assignment should yield undefined since it was invalid inside all
  // Layouts.
  equal(layout.options.key, undefined, "Layout: Invalid assignment");
  // The assignment should yield undefined since it was invalid inside all
  // Views.
  equal(view.options.key, undefined, "View: Invalid assignment");
});

// Test overriding a single property to ensure propagation works as expected.
test("global", 4, function() {
  // Configure prefix property globally.
  Backbone.Layout.configure({
    prefix: "/templates/",

    manage: true
  });

  // Create a new Layout to test.
  var layout = new this.Layout();
  // Create a new View to test.
  var view = new this.View();

  // The template property set inside prefix should be default for all new
  // Layouts.
  equal(layout.options.prefix, "/templates/",
    "Layout: Override paths globally for Layouts");
  // The template property set inside paths should be default for all new
  // Views.
  equal(view.options.prefix, "/templates/",
    "View: Override paths globally for Views");
  // Ensure the global configuration was updated to reflect this update.
  equal(this.Layout.prototype.options.prefix, "/templates/",<commit_msg>Remove invalid test<commit_after>(function(window) {
"use strict";

/* 
 * Test Module: Configure
 * Ensures that configuration settings have correct defaults, initialization,
 * overriding, and functionality.
 *
 */
QUnit.module("configure", {
  setup: function() {
    // Backbone.Layout constructor.
    this.Layout = Backbone.Layout;

    // Normal Backbone.View.
    this.View = Backbone.View.extend({
      initialize: function(options) {
        // Set up this View with Layout.
        Backbone.Layout.setupView(this, options);
      }
    });

    // Save a copy of console.warn.
    this.warn = window.console.warn;
  },

  teardown: function() {
    // Ensure the prefix object is restored correctly.
    this.Layout.prototype.options.prefix = "";

    // Remove `manage: true`.
    delete this.Layout.prototype.options.manage;
    delete Backbone.View.prototype.manage;

    // Remove `serialize` option.
    delete this.Layout.prototype.options.serialize;
    delete Backbone.View.prototype.serialize;

    // Remove `el: false`.
    delete this.Layout.prototype.options.el;
    delete Backbone.View.prototype.el;

    // Remove `supressWarnings: true`.
    delete this.Layout.prototype.options.suppressWarnings;
    delete Backbone.View.prototype.suppressWarnings;

    // Not necessary for our testing purposes.
    window.console.trace = function() {};

    // Restore console.warn.
    window.console.warn = this.warn;
    delete this.warn;
  }
});

// Ensure the correct defaults are set for all Layout and View options.
test("defaults", 18, function() {
  // Create a new Layout to test.
  var layout = new this.Layout();
  // Create a new Layout to test.
  var view = new this.View();

  // Paths should be an empty object.
  deepEqual(layout.options.prefix, "", "Layout: No prefix");
  // The deferred property should be a function.
  ok(_.isFunction(layout.options.deferred), "Layout: deferred is a function");
  // The fetch property should be a function.
  ok(_.isFunction(layout.options.fetch), "Layout: fetch is a function");
  // The partial property should be a function.
  ok(_.isFunction(layout.options.partial), "Layout: partial is a function");
  // The html property should be a function.
  ok(_.isFunction(layout.options.html), "Layout: html is a function");
  // The insert property should be a function.
  ok(_.isFunction(layout.options.insert), "Layout: insert is a function");
  // The append property should be a function.
  ok(_.isFunction(layout.options.insert), "Layout: append is a function");
  // The when property should be a function.
  ok(_.isFunction(layout.options.when), "Layout: when is a function");
  // The render property should be a function.
  ok(_.isFunction(layout.options.render), "Layout: render is a function");
  // Paths should be an empty object.
  deepEqual(view.options.prefix, "", "View: No prefix");
  // The deferred property should be a function.
  ok(_.isFunction(view.options.deferred), "View: deferred is a function");
  // The fetch property should be a function.
  ok(_.isFunction(view.options.fetch), "View: fetch is a function");
  // The partial property should be a function.
  ok(_.isFunction(view.options.partial), "View: partial is a function");
  // The html property should be a function.
  ok(_.isFunction(view.options.html), "View: html is a function");
  // The insert property should be a function.
  ok(_.isFunction(view.options.insert), "View: insert is a function");
  // The append property should be a function.
  ok(_.isFunction(view.options.insert), "View: append is a function");
  // The when property should be a function.
  ok(_.isFunction(view.options.when), "View: when is a function");
  // The render property should be a function.
  ok(_.isFunction(view.options.render), "View: render is a function");
});

// Test overriding a single property to ensure propagation works as expected.
test("global", 4, function() {
  // Configure prefix property globally.
  Backbone.Layout.configure({
    prefix: "/templates/",

    manage: true
  });

  // Create a new Layout to test.
  var layout = new this.Layout();
  // Create a new View to test.
  var view = new this.View();

  // The template property set inside prefix should be default for all new
  // Layouts.
  equal(layout.options.prefix, "/templates/",
    "Layout: Override paths globally for Layouts");
  // The template property set inside paths should be default for all new
  // Views.
  equal(view.options.prefix, "/templates/",
    "View: Override paths globally for Views");
  // Ensure the global configuration was updated to reflect this update.
  equal(this.Layout.prototype.options.prefix, "/templates/",
{'fraction_non_alphanumeric': 0.12279116465863454, 'fraction_numerical': 0.0007028112449799197, 'mean_word_length': 3.3612084063047285, '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': '4394664', 'n_tokens_mistral': 2810, 'n_tokens_neox': 2747, 'n_words': 987}