Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rewrite the ‘maximum’ test into Mocha

  • Loading branch information...
commit 05bd651e5587490039f598fb8e03dbcf9cc98151 1 parent 2fb9672
František Hába authored
Showing with 71 additions and 0 deletions.
  1. +71 −0 tests/json/attributes/maximum.js
71 tests/json/attributes/maximum.js
View
@@ -0,0 +1,71 @@
+if (typeof module !== 'undefined' && module.exports) {
+ var expect = require('expect.js');
+ var Amanda = require('../../../dist/latest.js');
+}
+
+/**
+ * Maximum
+ * --------------------
+ */
+suite('JSON/Attribute/maximum', function() {
+
+ var count = 0;
+
+ /**
+ * Schema
+ */
+ var schema = {
+ type: 'number',
+ maximum: 10
+ };
+
+ /**
+ * Validator
+ */
+ var Validator = new Amanda('json');
+
+ test('should return an error', function() {
+ [
+ 11,
+ 12,
+ 13,
+ 14,
+ 15,
+ 20,
+ 100,
+ 1000,
+ 10000
+ ].forEach(function(input) {
+ Validator.validate(input, schema, function(error) {
+ count += 1;
+ expect(error).to.be.ok();
+ });
+ });
+ });
+
+ test('should not return an error', function() {
+ [
+ 0,
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10
+ ].forEach(function(input) {
+ Validator.validate(input, schema, function(error) {
+ count += 1;
+ expect(error).to.not.be.ok();
+ });
+ });
+ });
+
+ test('should run 20 times', function() {
+ expect(count).to.be.eql(20);
+ });
+
+});
Please sign in to comment.
Something went wrong with that request. Please try again.