Permalink
Browse files

Rewrite the ‘array’ test into Mocha

  • Loading branch information...
1 parent 3d6507f commit f6861116ed446d7bf147d04ad8e2e50aca001e2c @Baggz committed Mar 7, 2012
Showing with 60 additions and 0 deletions.
  1. +60 −0 tests/json/attributes/type/array.js
@@ -0,0 +1,60 @@
+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: 'array'
+ };
+
+ /**
+ * Validator
+ */
+ var Validator = new Amanda('json');
+
+ test('should not return an error', function() {
+ [
+ [],
+ [1, 2, 3],
+ ['a', 'b', 'c'],
+ [function() {}, function() {}],
+ [{}, {}, {}]
+ ].forEach(function(instance) {
+ Validator.validate(instance, schema, function(error) {
+ count += 1;
+ expect(error).to.not.be.ok();
+ });
+ });
+ });
+
+ test('should return an error', function() {
+ [
+ 'Hello',
+ 123,
+ true,
+ {},
+ function() {}
+ ].forEach(function(instance) {
+ Validator.validate(instance, schema, function(error) {
+ count += 1;
+ expect(error).to.be.ok();
+ });
+ });
+ });
+
+ test('should run 10 times', function() {
+ expect(count).to.be.eql(10);
+ });
+
+});

0 comments on commit f686111

Please sign in to comment.