<commit_before>describe("User", function() {

  var userController;

  beforeEach(function () {
    loadFixtures('menu.html');
    userController = new Teikei.User.Controller();
  });

  it("should contain a model.", function() {
    expect(userController.model).toBeInstanceOf(Teikei.User.Model);
  });

  it("should contain a MenuView.", function() {
    expect(userController.menuView).toBeInstanceOf(Teikei.User.MenuView);
  });

  it("should contain a LoginView.", function() {
    expect(userController.loginView).toBeInstanceOf(Teikei.User.LoginView);
  });

  describe("MenuView", function() {

    it("should fire a 'login:selected' event when the login link is clicked.", function() {
      var callback = jasmine.createSpy();
      userController.menuView.bind("login:selected", callback, this);
      $("#login").trigger("click");

      expect(callback).toHaveBeenCalled();
    });

    it("should fire a 'logout:selected' event when the logout link is clicked.", function() {
      var callback = jasmine.createSpy();
      userController.menuView.bind("logout:selected", callback, this);
      userController.model.set("loggedIn", true);
      $("#login").trigger("click");

      expect(callback).toHaveBeenCalled();
    });

    it("should toggle the login/logout link to 'logout' once the user is logged in.", function() {
      Teikei.vent.trigger("user:signin:success");
      expect($("#login")).toHaveText("Abmelden");
    });

    it("should toggle the login/logout link to 'login' once the user is logged in.", function() {
      Teikei.vent.trigger("user:logout:success");
      expect($("#login")).toHaveText("Anmelden");
    });

  });

  describe("LoginView", function() {

    beforeEach(function() {
      // Mock the $.ajax function to prevent XHR:
      spyOn($, "ajax").andCallFake(function(params) {});
    });

    it("should contain a form.", function() {
      expect(userController.loginView.$el).toContain("form");
    });

    it("should contain input fields for username and password.", function() {
      expect(userController.loginView.$el).toContain("input[type='text']#email");
      expect(userController.loginView.$el).toContain("input[type='password']#password");
    });

    it("should be presented in a modal view.", function() {
      expect(userController.loginView.$el).toHaveClass("reveal-modal");
    });

    it("should fire a 'signInForm:submit' event when the form is submitted.", function() {
      var callback = jasmine.createSpy("FormSubmitSpy");

      // Stub the form validation:
      spyOn(userController.loginView.signInForm, "validate").andCallFake(function(params) {
        return null;
      });

      userController.loginView.bind("signInForm:submit", callback, this);
      userController.loginView.ui.signInForm.trigger("submit");

      expect(callback).toHaveBeenCalled();
    });

    it("should pass email and password with the 'signInForm:submit' event.", function() {
      var email = "<EMAIL>";
      var password = "<PASSWORD>";
      var callback = jasmine.createSpy("FormSubmitSpy");

      userController.loginView.$el.find("#email").val(email);
      userController.loginView.$el.find("#password").val(password);
      userController.loginView.bind("signInForm:submit", callback, this);
      userController.loginView.ui.signInForm.trigger("submit");

      expect(callback).toHaveBeenCalledWith({
        email: email,
        password: password
      });
    });

    it("should close the modal view when the signin was successful.", function() {
      spyOn(userController.loginView.$el, "trigger");
      Teikei.vent.trigger("user:signin:success");
      expect(userController.loginView.$el.trigger).toHaveBeenCalledWith("reveal:close");
    });

  });

});
<commit_msg>Add test for hiding signup popup.<commit_after>describe("User", function() {

  var userController;

  beforeEach(function () {
    loadFixtures('menu.html');
    userController = new Teikei.User.Controller();
  });

  it("should contain a model.", function() {
    expect(userController.model).toBeInstanceOf(Teikei.User.Model);
  });

  it("should contain a MenuView.", function() {
    expect(userController.menuView).toBeInstanceOf(Teikei.User.MenuView);
  });

  it("should contain a LoginView.", function() {
    expect(userController.loginView).toBeInstanceOf(Teikei.User.LoginView);
  });

  describe("MenuView", function() {

    it("should fire a 'login:selected' event when the login link is clicked.", function() {
      var callback = jasmine.createSpy();
      userController.menuView.bind("login:selected", callback, this);
      $("#login").trigger("click");

      expect(callback).toHaveBeenCalled();
    });

    it("should fire a 'logout:selected' event when the logout link is clicked.", function() {
      var callback = jasmine.createSpy();
      userController.menuView.bind("logout:selected", callback, this);
      userController.model.set("loggedIn", true);
      $("#login").trigger("click");

      expect(callback).toHaveBeenCalled();
    });

    it("should toggle the login/logout link to 'logout' once the user is logged in.", function() {
      Teikei.vent.trigger("user:signin:success");
      expect($("#login")).toHaveText("Abmelden");
    });

    it("should toggle the login/logout link to 'login' once the user is logged in.", function() {
      Teikei.vent.trigger("user:logout:success");
      expect($("#login")).toHaveText("Anmelden");
    });

  });

  describe("LoginView", function() {

    beforeEach(function() {
      // Mock the $.ajax function to prevent XHR:
      spyOn($, "ajax").andCallFake(function(params) {});
    });

    it("should contain a form.", function() {
      expect(userController.loginView.$el).toContain("form");
    });

    it("should contain input fields for username and password.", function() {
      expect(userController.loginView.$el).toContain("input[type='text']#email");
      expect(userController.loginView.$el).toContain("input[type='password']#password");
    });

    it("should be presented in a modal view.", function() {
      expect(userController.loginView.$el).toHaveClass("reveal-modal");
    });

    it("should fire a 'signInForm:submit' event when the form is submitted.", function() {
      var callback = jasmine.createSpy("FormSubmitSpy");

      // Stub the form validation:
      spyOn(userController.loginView.signInForm, "validate").andCallFake(function(params) {
        return null;
      });

      userController.loginView.bind("signInForm:submit", callback, this);
      userController.loginView.ui.signInForm.trigger("submit");

      expect(callback).toHaveBeenCalled();
    });

    it("should pass email and password with the 'signInForm:submit' event.", function() {
      var email = "<EMAIL>";
      var password = "<PASSWORD>";
      var callback = jasmine.createSpy("FormSubmitSpy");

      userController.loginView.$el.find("#email").val(email);
      userController.loginView.$el.find("#password").val(password);
      userController.loginView.bind("signInForm:submit", callback, this);
      userController.loginView.ui.signInForm.trigger("submit");

      expect(callback).toHaveBeenCalledWith({
        email: email,
        password: password
      });
    });

    it("should close the modal view when the signin was successful.", function() {
      spyOn(userController.loginView.$el, "trigger");
      Teikei.vent.trigger("user:signin:success");
      expect(userController.loginView.$el.trigger).toHaveBeenCalledWith("reveal:close");
    });

    it("should close the modal view when the signup was successful.", function() {
      spyOn(userController.loginView.$el, "trigger");
      Teikei.vent.trigger("user:signup:success");
      expect(userController.loginView.$el.trigger).toHaveBeenCalledWith("reveal:close");
    });

  });

});

{'fraction_non_alphanumeric': 0.15894293374186136, 'fraction_numerical': 0.0, 'mean_word_length': 3.841779975278121, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6587103', 'n_tokens_mistral': 2272, 'n_tokens_neox': 2222, 'n_words': 446}