Permalink
Browse files

Rewrite the ‘object’ test into Mocha

  • Loading branch information...
1 parent f58b92f commit e10f95daf014a5062faca54c461c214a27cb8c11 @Baggz committed Mar 7, 2012
Showing with 56 additions and 0 deletions.
  1. +56 −0 tests/json/attributes/type/object.js
@@ -0,0 +1,56 @@
+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: 'object'
+ };
+
+ /**
+ * Validator
+ */
+ var Validator = new Amanda('json');
+
+ test('should not return an error', 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 6 times', function() {
+ expect(count).to.be.eql(6);
+ });
+
+});

0 comments on commit e10f95d

Please sign in to comment.