Permalink
Browse files

Rewrite the ‘unsignedInt’ test suite into Mocha

  • Loading branch information...
1 parent 57ae3b9 commit 04d5978ea9310a9e53ad28bcec6a902f5fb9ac6a @Baggz committed Mar 7, 2012
Showing with 59 additions and 0 deletions.
  1. +59 −0 tests/json/attributes/format/unsignedInt.js
@@ -0,0 +1,59 @@
+if (typeof module !== 'undefined' && module.exports) {
+ var expect = require('expect.js');
+ var Amanda = require('../../../../dist/latest.js');
+}
+
+/**
+ * Format
+ * --------------------
+ */
+suite('JSON/Attribute/format#unsignedInt', function() {
+
+ var count = 0;
+
+ /**
+ * Schema
+ */
+ var schema = {
+ format: 'unsignedInt'
+ };
+
+ /**
+ * Validator
+ */
+ var Validator = new Amanda('json');
+
+ test('should not return an error', function() {
+ [
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6
+ ].forEach(function(data) {
+ Validator.validate(data, schema, function(error) {
+ count += 1;
+ expect(error).to.not.be.ok();
+ });
+ });
+ });
+
+ test('should return an error', function() {
+ [
+ -1212,
+ -2112,
+ -12.21
+ ].forEach(function(data) {
+ Validator.validate(data, schema, function(error) {
+ count += 1;
+ expect(error).to.be.ok();
+ });
+ });
+ });
+
+ test('should run 9 times', function() {
+ expect(count).to.be.eql(9);
+ });
+
+});

0 comments on commit 04d5978

Please sign in to comment.