Permalink
Browse files

Rewrite the ‘pattern’ test into Mocha

  • Loading branch information...
1 parent 2998b66 commit 3d6507f2ad4f410e9f1911bc8fb0d483b5668134 @Baggz committed Mar 7, 2012
Showing with 45 additions and 0 deletions.
  1. +45 −0 tests/json/attributes/pattern.js
@@ -0,0 +1,45 @@
+if (typeof module !== 'undefined' && module.exports) {
+ var expect = require('expect.js');
+ var Amanda = require('../../../dist/latest.js');
+}
+
+/**
+ * Pattern
+ * --------------------
+ */
+suite('JSON/Attribute/pattern', function() {
+
+ var count = 0;
+
+ /**
+ * Schema
+ */
+ var schema = {
+ type: 'string',
+ pattern: /a/
+ };
+
+ /**
+ * Validator
+ */
+ var Validator = new Amanda('json');
+
+ test('should not return an error', function() {
+ Validator.validate('hola', schema, function(error) {
+ count += 1;
+ expect(error).to.not.be.ok();
+ });
+ });
+
+ test('should return an error', function() {
+ Validator.validate('hello', schema, function(error) {
+ count += 1;
+ expect(error).to.be.ok();
+ });
+ });
+
+ test('should run 2 times', function() {
+ expect(count).to.be.eql(2);
+ });
+
+});

0 comments on commit 3d6507f

Please sign in to comment.