Sha256: 02385bf6ffe3a713cc4135ad631530188e5383f0a0edc50e841dd8c876ddf5aa
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
FormElement = require "hoarder/form/form_element" FormValidator = require "hoarder/validator/form_validator" describe "FormValidator", -> validator = null element = null beforeEach -> validator = FormValidator.default() element = new FormElement("element", "$", "test-element", [ "alphanumeric", "creditCard", "email", "maxLength=5", "minLength=5", "numeric", "phone", "required" ]) it "can validate an element", -> errors = validator.validateElement(element) jasmine.log errors expect(errors[0].message).toEqual "This field only accepts numbers and characters (0-9, A-Z, a-z)." element.value = "4111111111111111" errors = validator.validateElement(element) jasmine.log errors expect(errors[0].message).toEqual "Please enter a valid email address." element.value = "6854291" errors = validator.validateElement(element) jasmine.log errors expect(errors[0].message).toEqual "Please enter a valid credit card number." it "can validate a form", -> errors = validator.validateForm(mocks.simpleForm) expect(errors.length).toEqual 0 errors = validator.validateForm(mocks.invalidForm) expect(errors.length).toEqual 4
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hoarder-js-0.0.1 | spec/tests/validator/form_validator_spec.coffee |