Fix tests

This commit is contained in:
Nicolas Le Goff
2013-06-17 12:17:44 +02:00
parent 164d012437
commit c509a1bf47
4 changed files with 16 additions and 11 deletions

View File

@@ -17,11 +17,11 @@ define([
initialize: function(options) { initialize: function(options) {
options = options || {}; options = options || {};
if (! "name" in options) { if (false === "name" in options) {
throw "Missing name attribute in error view"; throw "Missing name attribute in error view";
} }
if (! "errorTemplate" in options) { if (false === "errorTemplate" in options) {
throw "Missing errorTemplate attribute in error view"; throw "Missing errorTemplate attribute in error view";
} }

View File

@@ -18,11 +18,11 @@ define([
initialize: function(options) { initialize: function(options) {
options = options || {}; options = options || {};
if (! "name" in options) { if (false === "name" in options) {
throw "Missing name attribute in input view"; throw "Missing name attribute in input view";
} }
if (! "errorTemplate" in options) { if (false === "errorTemplate" in options) {
throw "Missing errorTemplate attribute in input view"; throw "Missing errorTemplate attribute in input view";
} }

View File

@@ -2,9 +2,9 @@ define([
'chai', 'chai',
'fixtures', 'fixtures',
'jquery', 'jquery',
'apps/login/home/views/form', 'common/forms/views/form',
'apps/login/home/views/input', 'common/forms/views/input',
'apps/login/home/views/error' 'common/forms/views/error'
], function( ], function(
chai, chai,
fixtures, fixtures,
@@ -65,7 +65,8 @@ define([
describe("Input View", function() { describe("Input View", function() {
it("should initialize error view", function() { it("should initialize error view", function() {
var input = new InputView({ var input = new InputView({
"name": "test" "name": "test",
"errorTemplate": "#field_errors"
}); });
expect(input.errorView).to.be.an.instanceof(ErrorView); expect(input.errorView).to.be.an.instanceof(ErrorView);
}); });
@@ -79,8 +80,10 @@ define([
}; };
var errorView = new ErrorView({ var errorView = new ErrorView({
"name": "test",
"errors": [error], "errors": [error],
"el" : $(".error-view").first() "el" : $(".error-view").first(),
"errorTemplate": "#field_errors"
}); });
errorView.render(); errorView.render();
@@ -94,8 +97,10 @@ define([
$el.html('previous error here'); $el.html('previous error here');
var errorView = new ErrorView({ var errorView = new ErrorView({
"name": "test",
"errors": [], "errors": [],
"el" : $el "el" : $el,
"errorTemplate": "#field_errors"
}); });
errorView.render(); errorView.render();

View File

@@ -1,6 +1,6 @@
define([ define([
'chai', 'chai',
'common/validator' 'common/forms/validator'
], function(chai, Validator) { ], function(chai, Validator) {
var expect = chai.expect; var expect = chai.expect;
var assert = chai.assert; var assert = chai.assert;