Permalink
Browse files

Rewrite the ‘string’ test into Mocha

  • Loading branch information...
1 parent e10f95d commit d1b805e7f698c1981ec06e8ccb9b6422b456119e @Baggz committed Mar 7, 2012
Showing with 57 additions and 0 deletions.
  1. +57 −0 tests/json/attributes/type/string.js
View
57 tests/json/attributes/type/string.js
@@ -0,0 +1,57 @@
+if (typeof module !== 'undefined' && module.exports) {
+ var expect = require('expect.js');
+ var Amanda = require('../../../../dist/latest.js');
+}
+
+/**
+ * Type
+ * --------------------
+ */
+suite('JSON/Attribute/type#array', function() {
+
+ var count = 0;
+
+ /**
+ * Schema
+ */
+ var schema = {
+ type: 'string'
+ };
+
+ /**
+ * Validator
+ */
+ var Validator = new Amanda('json');
+
+ test('should not return an error', function() {
+ [
+ 'Hello',
+ '123'
+ ].forEach(function(instance) {
+ Validator.validate(instance, schema, function(error) {
+ count += 1;
+ expect(error).to.not.be.ok();
+ });
+ });
+ });
+
+ test('should return an error', function() {
+ [
+ 123,
+ true,
+ {},
+ [],
+ function() {},
+ ].forEach(function(instance) {
+ Validator.validate(instance, schema, function(error) {
+ count += 1;
+ expect(error).to.be.ok();
+ });
+ });
+ });
+
+ test('should run 7 times', function() {
+ expect(count).to.be.eql(7);
+ });
+
+});

0 comments on commit d1b805e

Please sign in to comment.