Skip to content
Browse files

Rewrite the ‘minLength’ test into Mocha

  • Loading branch information...
1 parent 339d90c commit 2998b66c339789bb42699edf0dc59c871e550bd3 @Baggz committed Mar 7, 2012
Showing with 64 additions and 0 deletions.
  1. +64 −0 tests/json/attributes/minLength.js
View
64 tests/json/attributes/minLength.js
@@ -0,0 +1,64 @@
+if (typeof module !== 'undefined' && module.exports) {
+ var expect = require('expect.js');
+ var Amanda = require('../../../dist/latest.js');
+}
+
+/**
+ * MinLength
+ * --------------------
+ */
+suite('JSON/Attribute/minLength', function() {
+
+ var count = 0;
+
+ /**
+ * Schema
+ */
+ var schema = {
+ type: 'string',
+ minLength: 10
+ };
+
+ /**
+ * Validator
+ */
+ var Validator = new Amanda('json');
+
+ test('should not return an error', function() {
+ [
+ 'abcdefghij',
+ 'abcdefghijk',
+ 'abcdefghijkl',
+ 'abcdefghijklm'
+ ].forEach(function(input) {
+ Validator.validate(input, schema, function(error) {
+ count += 1;
+ expect(error).to.not.be.ok();
+ });
+ });
+ });
+
+ test('should return an error', function() {
+ [
+ 'a',
+ 'ab',
+ 'abc',
+ 'abcd',
+ 'abcde',
+ 'abcdef',
+ 'abcdefg',
+ 'abcdefgh',
+ 'abcdefghi'
+ ].forEach(function(input) {
+ Validator.validate(input, schema, function(error) {
+ count += 1;
+ expect(error).to.be.ok();
+ });
+ });
+ });
+
+ test('should run 13 times', function() {
+ expect(count).to.be.eql(13);
+ });
+
+});

0 comments on commit 2998b66

Please sign in to comment.
Something went wrong with that request. Please try again.