Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rewrite the ‘function’ test into Mocha

  • Loading branch information...
commit d1ef558d3595269e8e10dc112087b4575a29effc 1 parent b831ef1
@Baggz authored
Showing with 57 additions and 0 deletions.
  1. +57 −0 tests/json/attributes/type/function.js
View
57 tests/json/attributes/type/function.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#function', function() {
+
+ var count = 0;
+
+ /**
+ * Schema
+ */
+ var schema = {
+ type: 'function'
+ };
+
+ /**
+ * Validator
+ */
+ var Validator = new Amanda('json');
+
+ test('should not return an error', function() {
+ [
+ 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,
+ {},
+ []
+ ].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);
+ });
+
+});
Please sign in to comment.
Something went wrong with that request. Please try again.