Skip to content

Commit

Permalink
Rewrite the ‘decimal’ 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 388d248 commit 0b565d3
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions tests/json/attributes/format/decimal.js
@@ -0,0 +1,67 @@
if (typeof module !== 'undefined' && module.exports) {
var expect = require('expect.js');
var Amanda = require('../../../../dist/latest.js');
}

/**
* Format
* --------------------
*/
suite('JSON/Attribute/format#decimal', function() {

var count = 0;

/**
* Schema
*/
var schema = {
format: 'decimal'
};

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

test('should not return an error', function() {
[
1,
10,
20,
30,
1.11,
1.23,
1.30,
230.36
].forEach(function(data) {
Validator.validate(data, schema, function(error) {
count += 1;
expect(error).to.not.be.ok();
});
});
});

test('should return an error', function() {
[
1.123981273,
19723.129319,
'+@#$~^*{}',
'lorem ipsum',
' ',
null,
[],
{},
function() {}
].forEach(function(instance) {
Validator.validate(instance, schema, function(error) {
count += 1;
expect(error).to.be.ok();
});
});
});

test('should run 17 times', function() {
expect(count).to.be.eql(17);
});

});

0 comments on commit 0b565d3

Please sign in to comment.