Skip to content

Commit

Permalink
Rewrite the ‘minimum’ test into Mocha
Browse files Browse the repository at this point in the history
  • Loading branch information
František Hába committed Mar 7, 2012
1 parent 96b834e commit 5fcee78
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions tests/json/attributes/minimum.js
@@ -0,0 +1,71 @@
if (typeof module !== 'undefined' && module.exports) {
var expect = require('expect.js');
var Amanda = require('../../../dist/latest.js');
}

/**
* Minimum
* --------------------
*/
suite('JSON/Attribute/minimum', function() {

var count = 0;

/**
* Schema
*/
var schema = {
type: 'number',
minimum: 10
};

/**
* Validator
*/
var Validator = new Amanda('json');

test('should return an error', function() {
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
].forEach(function(input) {
Validator.validate(input, schema, function(error) {
count += 1;
expect(error).to.be.ok();
});
});
});

test('should not return an error', function() {
[
10,
11,
12,
13,
14,
15,
20,
100,
1000,
10000
].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);
});

});

0 comments on commit 5fcee78

Please sign in to comment.