Permalink
Browse files

Rewrite the ‘alpha’ test into Mocha

  • Loading branch information...
1 parent d1b805e commit 206fe94fe36f88d408b5fc65af6a16772e256cb3 @Baggz committed Mar 7, 2012
Showing with 59 additions and 0 deletions.
  1. +59 −0 tests/json/attributes/format/alpha.js
@@ -0,0 +1,59 @@
+if (typeof module !== 'undefined' && module.exports) {
+ var expect = require('expect.js');
+ var Amanda = require('../../../../dist/latest.js');
+}
+
+/**
+ * Format
+ * --------------------
+ */
+suite('JSON/Attribute/format#alpha', function() {
+
+ var count = 0;
+
+ /**
+ * Schema
+ */
+ var schema = {
+ type: 'string',
+ format: 'alpha'
+ };
+
+ /**
+ * Validator
+ */
+ var Validator = new Amanda('json');
+
+ test('should not return an error', function() {
+ [
+ 'abc',
+ 'ABC',
+ 'Abc',
+ 'aBc'
+ ].forEach(function(data) {
+ Validator.validate(data, schema, function(error) {
+ count += 1;
+ expect(error).to.not.be.ok();
+ });
+ });
+ });
+
+ test('should return an error', function() {
+ [
+ '123',
+ '+@#$~^*{}',
+ 'lorem ipsum',
+ ' '
+ ].forEach(function(data) {
+ Validator.validate(data, schema, function(error) {
+ count += 1;
+ expect(error).to.be.ok();
+ });
+ });
+ });
+
+ test('should run 8 times', function() {
+ expect(count).to.be.eql(8);
+ });
+
+});

0 comments on commit 206fe94

Please sign in to comment.