Permalink
Browse files

node 0.8

  • Loading branch information...
1 parent 3c6895a commit fbf0ec8dd561587ff0d2f69af4c68745c06be452 @vesln committed Jun 25, 2012
Showing with 58 additions and 38 deletions.
  1. +2 −1 .travis.yml
  2. +3 −4 Makefile
  3. +5 −5 package.json
  4. +8 −3 test/app.test.js
  5. +10 −5 test/cli.test.js
  6. +13 −8 test/commands.test.js
  7. +17 −12 test/storage.test.js
View
3 .travis.yml
@@ -1,3 +1,4 @@
language: node_js
node_js:
- - 0.6
+ - 0.6
+ - 0.8
View
7 Makefile
@@ -2,11 +2,10 @@ TESTS = test/*.test.js
test:
@NODE_ENV=test ./node_modules/.bin/mocha \
- --require should \
--reporter spec \
$(TESTS)
-
-init:
+
+init:
chmod 777 ./data
-.PHONY: test init
+.PHONY: test init
View
10 package.json
@@ -8,8 +8,8 @@
"flatiron": "~0.1.7"
}
, "devDependencies": {
- "mocha": "0.3.3"
- , "should": "0.3.2"
+ "mocha": "*"
+ , "chai": "*"
, "sinon": "1.3.1"
}
, "repository" : {
@@ -25,7 +25,7 @@
, "bin": {
"box": "./bin/box"
}
- , "engines": {
- "node": ">= 0.6.0 < 0.7.0"
+ , "engines": {
+ "node": ">= 0.6.0"
}
-}
+}
View
11 test/app.test.js
@@ -1,18 +1,23 @@
/*!
* Box - Powerful key -> value storage for the CLI.
- *
+ *
* Veselin Todorov <hi@vesln.com>
* MIT License.
*/
/**
+ * Support.
+ */
+var should = require('chai').should();
+
+/**
* Test dependencies.
*/
var flatiron = require('flatiron');
/**
* The tests object.
- *
+ *
* @type {Object}
*/
var app = require('../lib/app');
@@ -21,4 +26,4 @@ describe('app', function() {
it('should be flatiron app', function() {
app.should.eql(flatiron.app);
});
-});
+});
View
15 test/cli.test.js
@@ -1,19 +1,24 @@
/*!
* Box - Powerful key -> value storage for the CLI.
- *
+ *
* Veselin Todorov <hi@vesln.com>
* MIT License.
*/
/**
+ * Support.
+ */
+var should = require('chai').should();
+
+/**
* Test dependencies.
*/
var flatiron = require('flatiron');
var path = require('path');
/**
* The tests object.
- *
+ *
* @type {Object}
*/
var cli = require('../lib/cli');
@@ -28,11 +33,11 @@ describe('cli', function() {
it('should expose flatiron app', function() {
cli.should.eql(flatiron.app);
});
-
+
it('should configure the storage', function() {
storage.source.should.eql(path.join(__dirname, '..', 'data', 'config.json'));
});
-
+
it('should register routes', function() {
cli.router.routes.ls.on.should.eql(commands.list);
cli.router.routes.version.on.should.eql(commands.version);
@@ -41,4 +46,4 @@ describe('cli', function() {
cli.router.routes['([^\\s]+$)'].on.should.eql(commands.get);
cli.router.routes['([^\\s]+)']['(.+)'].on.should.eql(commands.set);
});
-});
+});
View
21 test/commands.test.js
@@ -1,10 +1,15 @@
/*!
* Box - Powerful key -> value storage for the CLI.
- *
+ *
* Veselin Todorov <hi@vesln.com>
* MIT License.
*/
-
+
+/**
+ * Support.
+ */
+var should = require('chai').should();
+
/**
* Module dependencies.
*/
@@ -17,7 +22,7 @@ var storage = require('../lib/storage');
/**
* The tests object.
- *
+ *
* @type {Object}
*/
var commands = require('../lib/commands');
@@ -28,7 +33,7 @@ describe('commands', function() {
commands.version.should.be.ok
});
});
-
+
describe('.delete()', function() {
it('should call storage.delete and storage.save', function() {
sinon.spy(storage, 'del');
@@ -41,7 +46,7 @@ describe('commands', function() {
storage.save.restore();
});
});
-
+
describe('.get()', function() {
it('should call storage.get', function() {
sinon.stub(storage, 'get');
@@ -51,7 +56,7 @@ describe('commands', function() {
storage.get.restore();
});
});
-
+
describe('.set()', function() {
it('should call storage.set and storage.save', function() {
sinon.spy(storage, 'set');
@@ -65,7 +70,7 @@ describe('commands', function() {
storage.save.restore();
});
});
-
+
describe('.list()', function() {
it('should call storage.get with no params', function() {
sinon.stub(storage, 'get');
@@ -74,4 +79,4 @@ describe('commands', function() {
storage.get.restore();
});
});
-});
+});
View
29 test/storage.test.js
@@ -1,26 +1,31 @@
/*!
* Box - Powerful key -> value storage for the CLI.
- *
+ *
* Veselin Todorov <hi@vesln.com>
* MIT License.
*/
/**
+ * Support.
+ */
+var should = require('chai').should();
+
+/**
* Test dependencies.
*/
var fs = require('fs');
var path = require('path');
/**
* The tested object.
- *
+ *
* @type {Object}
*/
var storage = require('../lib/storage');
/**
* Temporary data file.
- *
+ *
* @type {String}
*/
var file = path.join(__dirname, 'tmp', 'data.json');
@@ -39,7 +44,7 @@ function rm() {
describe('storage', function() {
beforeEach(rm);
afterEach(rm);
-
+
describe('.load()', function() {
it('should load file content', function(done) {
storage.load(file, function(err) {
@@ -48,7 +53,7 @@ describe('storage', function() {
});
});
});
-
+
describe('.set() \n .get()', function() {
it('should access a key value', function(done) {
storage.set('foo', 'bar', function() {
@@ -58,7 +63,7 @@ describe('storage', function() {
})
});
});
-
+
it('should return all the stored data when no key is passed', function(done) {
storage.set('foo', 'bar', function() {
storage.get(function(val) {
@@ -68,7 +73,7 @@ describe('storage', function() {
});
});
});
-
+
describe('.del()', function() {
it('should delete a key', function(done) {
storage.set('foo', 'bar', function() {
@@ -79,9 +84,9 @@ describe('storage', function() {
});
});
});
- });
+ });
});
-
+
describe('.save()', function() {
it('should save content to file.', function(done) {
storage.load(file, function(err) {
@@ -94,9 +99,9 @@ describe('storage', function() {
})
});
});
- });
+ });
});
-
+
describe('.destroy()', function() {
it('should destroy the loaded file.', function(done) {
storage.load(file, function(err) {
@@ -112,4 +117,4 @@ describe('storage', function() {
});
});
});
-});
+});

0 comments on commit fbf0ec8

Please sign in to comment.