mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Enhance tests
This commit is contained in:
@@ -13,7 +13,7 @@ require([
|
|||||||
"i18n",
|
"i18n",
|
||||||
"apps/login/home/common",
|
"apps/login/home/common",
|
||||||
"apps/login/home/views/form"
|
"apps/login/home/views/form"
|
||||||
], function(Common, RegisterForm) {
|
], function($, i18n, Common, RegisterForm) {
|
||||||
Common.initialize();
|
Common.initialize();
|
||||||
|
|
||||||
var fieldsConfiguration = [];
|
var fieldsConfiguration = [];
|
||||||
@@ -26,7 +26,7 @@ require([
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
]).done(function(){
|
]).done(function(){
|
||||||
$.i18n.init({
|
i18n.init({
|
||||||
resGetPath: Common.languagePath
|
resGetPath: Common.languagePath
|
||||||
}, function() {
|
}, function() {
|
||||||
var rules = [{
|
var rules = [{
|
||||||
|
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="row-fluid">
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<label for="login" class="required">Login</label>
|
<label for="login" class="required">Login</label>
|
||||||
|
@@ -22,7 +22,7 @@ define([
|
|||||||
|
|
||||||
describe("Login Home", function() {
|
describe("Login Home", function() {
|
||||||
describe("Form View", 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 rules = [{name: "hello",rules: "simple_rules"}];
|
||||||
var form = new FormView({
|
var form = new FormView({
|
||||||
el: $('form[name=loginForm]'),
|
el: $('form[name=loginForm]'),
|
||||||
@@ -31,7 +31,7 @@ define([
|
|||||||
form.validator.getRules().should.equal(rules);
|
form.validator.getRules().should.equal(rules);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be initialize input views", function() {
|
it("should initialize input views", function() {
|
||||||
var form = new FormView({
|
var form = new FormView({
|
||||||
el: $('form[name=loginForm]')
|
el: $('form[name=loginForm]')
|
||||||
});
|
});
|
||||||
@@ -39,13 +39,27 @@ define([
|
|||||||
Object.keys(form.inputViews).length.should.equal(5);
|
Object.keys(form.inputViews).length.should.equal(5);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should be initialize errors", function() {
|
it("should initialize errors", function() {
|
||||||
var form = new FormView({
|
var form = new FormView({
|
||||||
el: $('form[name=loginForm]')
|
el: $('form[name=loginForm]')
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.isTrue(_.isEmpty(form.validator.getErrors()));
|
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() {
|
describe("Input View", function() {
|
||||||
|
Reference in New Issue
Block a user