este-library-oldschool
Version:
Library for github.com/steida/este.git
35 lines • 1.12 kB
JavaScript
// Generated by github.com/steida/coffee2closure 900.1.18
suite('este.validators.maxLength', function() {
var maxLength;
maxLength = null;
setup(function() {
return maxLength = este.validators.maxLength(3)();
});
suite('validate', function() {
suite('should be valid:', function() {
return test('abc', function() {
maxLength.value = 'abc';
return assert.isTrue(maxLength.validate());
});
});
return suite('should be invalid:', function() {
return test('abcd', function() {
maxLength.value = 'abcd';
return assert.isFalse(maxLength.validate());
});
});
});
return suite('getMsg', function() {
test('should return message', function() {
return assert.equal(maxLength.getMsg(), 'Please enter no more than 3 characters.');
});
return test('should return alternative message', function() {
var getMsg;
getMsg = function() {
return "Foo " + this.maxLength;
};
maxLength = este.validators.maxLength(3, getMsg)();
return assert.equal(maxLength.getMsg(), 'Foo 3');
});
});
});