mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 23:13:15 +00:00
Enhance tests
This commit is contained in:
2
www/scripts/tests/fixtures/home/login/form
vendored
2
www/scripts/tests/fixtures/home/login/form
vendored
@@ -1,4 +1,4 @@
|
||||
<form novalidate="" name="loginForm" method="POST" action="/login/authenticate/">
|
||||
<form novalidate="" name="loginForm" method="POST" action="#">
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<label for="login" class="required">Login</label>
|
||||
|
@@ -22,7 +22,7 @@ define([
|
||||
|
||||
describe("Login Home", function() {
|
||||
describe("Form View", function() {
|
||||
it("should be initialize validator with proper rules", function() {
|
||||
it("should initialize validator with proper rules", function() {
|
||||
var rules = [{name: "hello",rules: "simple_rules"}];
|
||||
var form = new FormView({
|
||||
el: $('form[name=loginForm]'),
|
||||
@@ -31,7 +31,7 @@ define([
|
||||
form.validator.getRules().should.equal(rules);
|
||||
});
|
||||
|
||||
it("should be initialize input views", function() {
|
||||
it("should initialize input views", function() {
|
||||
var form = new FormView({
|
||||
el: $('form[name=loginForm]')
|
||||
});
|
||||
@@ -39,13 +39,27 @@ define([
|
||||
Object.keys(form.inputViews).length.should.equal(5);
|
||||
});
|
||||
|
||||
it("should be initialize errors", function() {
|
||||
it("should initialize errors", function() {
|
||||
var form = new FormView({
|
||||
el: $('form[name=loginForm]')
|
||||
});
|
||||
|
||||
assert.isTrue(_.isEmpty(form.validator.getErrors()));
|
||||
});
|
||||
|
||||
it("should render errors on submit", function() {
|
||||
var form = new FormView({
|
||||
el: $('form[name=loginForm]'),
|
||||
rules: [{
|
||||
"name": "login",
|
||||
"rules": "required",
|
||||
"message" : "something is wrong"
|
||||
}]
|
||||
});
|
||||
|
||||
form._onSubmit(document.createEvent("Event"));
|
||||
assert.isTrue(form.inputViews["login"].errorView.$el.html().indexOf("something is wrong") !== -1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Input View", function() {
|
||||
|
Reference in New Issue
Block a user