describe("thin_man", function(){

  function getAjaxArg(arg_name){
    return $.ajax.calls.argsFor(0)[0][arg_name];
  }

  describe("AjaxLinkSubmission", function(){
    it("submits an ajax call with options", function(){
      var $link = affix('a[data-ajax-link="true"][data-ajax-target="#test_dom_id"][href="/url"][data-ajax-method="PATCH"][data-return-type="json"]');
      thin_man.AjaxLinkSubmission($link)
      spyOn($, 'ajax');
      $link.click();
      expect($.ajax).toHaveBeenCalled();
      expect(getAjaxArg("url")).toMatch("/url");
      expect(getAjaxArg("type")).toMatch("PATCH");
      expect(getAjaxArg("datatype")).toMatch("json");
    });

    it("ajaxSuccess", function(){
      var $link = affix('a[data-ajax-link="true"][data-ajax-target="#test_dom_id"][data-return-type="json"]');
      var $target = affix('#test_dom_id');
      var thin = new thin_man.AjaxLinkSubmission($link)
      thin.ajaxSuccess({ html: "Hello" }, 'success', Object)
      expect($target.html()).toEqual("Hello")
    });

    it("on ajaxSuccess focus on first element", function(){
      var $link = affix('a[data-ajax-link="true"][data-ajax-target="#test_dom_id"]');
      var $target = affix('#test_dom_id');
      var thin = new thin_man.AjaxLinkSubmission($link)
      var form = '<form><input type="text"><textarea>dummy</textarea></form>'
      thin.ajaxSuccess(form, 'success', Object)
      expect($target.html()).toEqual(form);
      expect($("[type='text']").length).toEqual(1);
      //Check if it's focused
      expect($("[type='text']").get(0)).toBe(document.activeElement);
    });
  });
});

@@ -1596,12 +1596,568 @@
 ;%0A  %7D);%0A
+%0A%0A  describe(%22AjaxFormSubmission%22, function()%7B%0A    it(%22submits an ajax call with options%22, function()%7B%0A      var $form = affix('form%5Bdata-ajax-form=%22true%22%5D%5Bmethod=%22PATCH%22%5D%5Baction=%22/url%22%5D');%0A      $form.affix('input%5Btype=%22text%22%5D%5Bname=%22name%22%5D%5Bvalue=%22Jon Snow%22%5D')%0A      thin_man.AjaxFormSubmission($form)%0A      spyOn($, 'ajax');%0A      $form.submit();%0A      expect($.ajax).toHaveBeenCalled();%0A      expect(getAjaxArg(%22url%22)).toMatch(%22/url%22);%0A      expect(getAjaxArg(%22type%22)).toMatch(%22PATCH%22);%0A      expect(getAjaxArg(%22datatype%22)).toMatch(%22html%22);%0A    %7D);%0A  %7D)%0A
 %7D);%0A

Add AjaxFormSubmission tests