Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added initial tests

  • Loading branch information...
commit 184f6f8f0973723ba6014fd279cf7fa2747d88fc 1 parent 99f635d
@angelini authored
Showing with 82 additions and 0 deletions.
  1. +5 −0 package.json
  2. +44 −0 tests/isInt-test.js
  3. +33 −0 tests/readResources-test.js
View
5 package.json
@@ -12,6 +12,11 @@
"engines": {
"node": ">=0.4.10"
},
+ "devDependencies": {
+ "connect": ">= 1.8.5",
+ "vows": ">= 0.6.1",
+ "request": ">= 2.9.3"
+ },
"licenses": [
{
"type": "MIT",
View
44 tests/isInt-test.js
@@ -0,0 +1,44 @@
+var vows = require('vows');
+var assert = require('assert');
+
+var resty = require('../lib/resty');
+var isInt = resty._isInt;
+
+vows.describe('Is Int').addBatch({
+ 'testing an integer Number': {
+ topic: function() {
+ return isInt(3);
+ },
+ 'is an int': function(topic) {
+ assert.isTrue(topic);
+ }
+ },
+
+ 'testing a float Number': {
+ topic: function() {
+ return isInt(3.123);
+ },
+ 'is not an int': function(topic) {
+ assert.isFalse(topic);
+ }
+ },
+
+ 'testing an integer String': {
+ topic: function() {
+ return isInt('3');
+ },
+ 'is an int': function(topic) {
+ assert.isTrue(topic);
+ }
+ },
+
+ 'testing a float String': {
+ topic: function() {
+ return isInt('3.123');
+ },
+ 'is an int': function(topic) {
+ assert.isFalse(topic);
+ }
+ }
+})['export'](module);
+
View
33 tests/readResources-test.js
@@ -0,0 +1,33 @@
+var vows = require('vows');
+var assert = require('assert');
+
+var resty = require('../lib/resty');
+var readResources = resty._readResources;
+
+vows.describe('Read Resources').addBatch({
+ 'Read a valid resource folder': {
+ topic: function() {
+ return readResources(__dirname + '/../example/resources');
+ },
+
+ 'nested resource is within parent': function(resources) {
+ assert.notEqual(resources.users.contacts, undefined);
+ },
+
+ 'each level contains a _main': function(resources) {
+ assert.notEqual(resources.users._main, undefined);
+ assert.notEqual(resources.songs._main, undefined);
+ assert.notEqual(resources.users.contacts._main, undefined);
+ },
+
+ '_main should have a Resource and Collection object': function(resources) {
+ assert.notEqual(resources.users._main.Resource, undefined);
+ assert.notEqual(resources.users._main.Collection, undefined);
+ },
+
+ '_main.Resource get should be a function': function(resources) {
+ assert.equal(typeof resources.users._main.Resource.get, 'function');
+ }
+ }
+})['export'](module);
+
Please sign in to comment.
Something went wrong with that request. Please try again.