<commit_before>describe('$(element).mutiny()', function() {
  beforeEach(function() {
    Mutiny.directive = {
      'init': function(){}
    };
    spyOn(Mutiny.directive, 'init');
  });

  afterEach(function() {
    delete Mutiny.directive;
  });

  describe("<div data-mutiny='directive' />", function() {
    beforeEach(function() {
      this.el = $("<div data-mutiny='directive' />");
    });

    it("invokes with empty options", function() {
      this.el.mutiny();
      expect(Mutiny.directive.init).wasCalledWith($(this.el[0]), {});
    });

    it("invokes with defaults", function() {
      Mutiny.directive.defaults = {'default': 'option'};
      this.el.mutiny();
      expect(Mutiny.directive.init).wasCalledWith($(this.el[0]), {'default': 'option'});
    });
  });

  describe('<div data-mutiny=\'{"directive": {"key": "value"}}\' />', function() {
    beforeEach(function() {
      this.el = $('<div data-mutiny=\'{"directive": {"key": "value"}}\' />');
    });

    it("invokes with options", function() {
      this.el.mutiny();
      expect(Mutiny.directive.init).wasCalledWith($(this.el[0]), {'key': 'value'});
    });

    it("invokes with defaults merged with options", function() {
      Mutiny.directive.defaults = {'default': 'option'};
      this.el.mutiny();
      expect(Mutiny.directive.init).wasCalledWith($(this.el[0]), {'default': 'option', 'key': 'value'});
    });

    it("invokes with overridden defaults", function() {
      Mutiny.directive.defaults = {'key': 'default'};
      this.el.mutiny();
      expect(Mutiny.directive.init).wasCalledWith($(this.el[0]), {'key': 'value'});
    });
  });

  describe('<div data-mutiny=\'{"directive": "string"}\' />', function() {
    beforeEach(function() {
      Mutiny.directive.string_arg = 'objectize';
      this.el = $('<div data-mutiny=\'{"directive": "string"}\' />');
    });

    it("converts options into {Mutiny.directive.string_arg: 'string'}", function() {
      this.el.mutiny();
      expect(Mutiny.directive.init).wasCalledWith($(this.el[0]), {'objectize': 'string'});
    });

    it("merges defaults with options", function() {
      Mutiny.directive.defaults = {'default': 'option'};
      this.el.mutiny();
      expect(Mutiny.directive.init).wasCalledWith($(this.el[0]), {'default': 'option', 'objectize': 'string'});
    });

    it("overrides defaults with options", function() {
      Mutiny.directive.defaults = {'objectize': 'default'};
      this.el.mutiny();
      expect(Mutiny.directive.init).wasCalledWith($(this.el[0]), {'objectize': 'string'});
    });
  });

  it("<div data-custom='directive'> requires 'custom' argument", function() {
    var el = $("<div data-custom='directive' />");
    el.mutiny('custom');
    expect(Mutiny.directive.init).wasCalled();
  });

  it("<div data-mutiny='nonexistent directive'>", function() {
    var el = $("<div data-mutiny='nonexistent directive' />");
    expect(function() {
      el.mutiny();
    }).toThrow('"nonexistent directive" not found');
  });
});<commit_msg>Jasmine test refactor<commit_after>describe('$(element).mutiny()', function() {
  beforeEach(function() {
    Mutiny.directive = {
      'init': function(){}
    };
    spyOn(Mutiny.directive, 'init');
  });

  afterEach(function() {
    delete Mutiny.directive;
  });

  describe("<div data-mutiny='directive' />", function() {
    beforeEach(function() {
      this.el = $("<div data-mutiny='directive' />");
    });

    it("invokes with empty options", function() {
      this.el.mutiny();
      expect(Mutiny.directive.init).wasCalledWith($(this.el[0]), {});
    });

    it("invokes with defaults", function() {
      Mutiny.directive.defaults = {'default': 'option'};
      this.el.mutiny();
      expect(Mutiny.directive.init).wasCalledWith($(this.el[0]), {'default': 'option'});
    });
  });

  describe('<div data-mutiny=\'{"directive": {"key": "value"}}\' />', function() {
    beforeEach(function() {
      this.el = $('<div data-mutiny=\'{"directive": {"key": "value"}}\' />');
    });

    it("invokes with options", function() {
      this.el.mutiny();
      expect(Mutiny.directive.init).wasCalledWith($(this.el[0]), {'key': 'value'});
    });

    it("invokes with defaults merged with options", function() {
      Mutiny.directive.defaults = {'default': 'option'};
      this.el.mutiny();
      expect(Mutiny.directive.init).wasCalledWith($(this.el[0]), {'default': 'option', 'key': 'value'});
    });

    it("invokes with overridden defaults", function() {
      Mutiny.directive.defaults = {'key': 'default'};
      this.el.mutiny();
      expect(Mutiny.directive.init).wasCalledWith($(this.el[0]), {'key': 'value'});
    });
  });

  describe('<div data-mutiny=\'{"directive": "string"}\' />', function() {
    beforeEach(function() {
      Mutiny.directive.string_arg = 'objectize';
      this.el = $('<div data-mutiny=\'{"directive": "string"}\' />');
    });

    it("converts options into {Mutiny.directive.string_arg: 'string'}", function() {
      this.el.mutiny();
      expect(Mutiny.directive.init).wasCalledWith($(this.el[0]), {'objectize': 'string'});
    });

    it("merges defaults with options", function() {
      Mutiny.directive.defaults = {'default': 'option'};
      this.el.mutiny();
      expect(Mutiny.directive.init).wasCalledWith($(this.el[0]), {'default': 'option', 'objectize': 'string'});
    });

    it("overrides defaults with options", function() {
      Mutiny.directive.defaults = {'objectize': 'default'};
      this.el.mutiny();
      expect(Mutiny.directive.init).wasCalledWith($(this.el[0]), {'objectize': 'string'});
    });
  });

  describe("<div data-custom='directive'>", function() {
    beforeEach(function() {
      this.el = $("<div data-custom='directive' />");
    });

    it("ignores standard mutiny calls", function() {
      this.el.mutiny();
      expect(Mutiny.directive.init).wasNotCalled();
    });

    it("triggers using argument", function() {
      this.el.mutiny('custom');
      expect(Mutiny.directive.init).wasCalled();
    });
  });

  describe("exceptions", function() {
    it("<div data-mutiny='nonexistent'> throws nonexistent directive", function() {
      var el = $("<div data-mutiny='nonexistent' />");
      expect(function() {
        el.mutiny();
      }).toThrow('"nonexistent" not found');
    });
  });
});
{'fraction_non_alphanumeric': 0.22323965898326492, 'fraction_numerical': 0.0025260498894853173, 'mean_word_length': 3.5575539568345325, 'pattern_counts': {'":': 12, '<': 23, '<?xml version=': 0, '>': 23, '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': '5791146', 'n_tokens_mistral': 2077, 'n_tokens_neox': 2059, 'n_words': 326}