fixed spec, jquery event binding doesnt call the function itself, but a 'clone' of the function

This commit is contained in:
root 2010-12-02 02:54:38 +03:00
parent 5cd0a60073
commit 5d31a24e9e
2 changed files with 5 additions and 12 deletions

View file

@ -1,3 +1,7 @@
/* Copyright (c) 2010, Diaspora Inc. This file is
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
var Validation = {
rules: {
username: {

View file

@ -11,23 +11,12 @@ describe("Validation", function() {
describe("events", function() {
it("contains all the events that use validation methods");
describe("usernameKeypress", function() {
beforeEach(function() {
$("#jasmine_content").html(
' <input id="user_username" name="user[username]" size="30" type="text">'
);
});
it("doesn't allow the user to type anything but letters, numbers and underscores", function() {
expect(Validation.rules.username.characters.test("*")).toBeFalsy();
expect(Validation.rules.username.characters.test("Aa_")).toBeTruthy();
expect(Validation.rules.username.characters.test("ffffffffffffffffffffffffffffffffff")).toBeFalsy();
});
it("is called when the user presses a key on #user_username") {
spyOn(Validation.events, "usernameKeypress");
$("#user_username").keypress();
expect(Validation.events.usernameKeypress).toHaveBeenCalled();
});
});
});
});
});