Skip to content
Browse files

Commands.list test.

  • Loading branch information...
1 parent 5c44ca8 commit bcb5e360cd9a43d89be225cec5256d6d80c0ad3a @vesln committed Jan 29, 2012
Showing with 58 additions and 1 deletion.
  1. +1 −1 lib/commands.js
  2. +57 −0 test/commands.test.js
View
2 lib/commands.js
@@ -46,7 +46,7 @@ var formatter = require('./formatter');
* @api public
*/
commands.version = function() {
- print(require('../package.json').version);
+ commands.print(require('../package.json').version);
};
/**
View
57 test/commands.test.js
@@ -0,0 +1,57 @@
+/*!
+ * todo - Todos in the CLI like what.
+ *
+ * Veselin Todorov <hi@vesln.com>
+ * MIT License.
+ */
+
+/**
+ * Module dependencies.
+ */
+var sinon = require('sinon');
+
+/**
+ * Support.
+ */
+var storage = require('../lib/storage');
+
+/**
+ * The tests object.
+ *
+ * @type {Object}
+ */
+var commands = require('../lib/commands');
+
+describe('commands', function() {
+ describe('.version()', function() {
+ it('should be sane', function() {
+ commands.version.should.be.ok
+ });
+ });
+
+ describe('.list()', function() {
+ it('should return list items', function(done) {
+ var i = 0;
+ var expected = 3;
+ var out = '';
+
+ sinon.stub(storage, 'get', function(key, cb) {
+ cb(null, [{text: 'Foo', done: false}]);
+ });
+
+ sinon.stub(commands, 'print', function(text) {
+ out += text;
+ if (++i === expected) finish();
+ });
+
+ function finish() {
+ out.should.eql(' #1 \u001b[31m✖\u001b[39m Foo');
+ commands.print.restore();
+ storage.get.restore();
+ done();
+ };
+
+ commands.list();
+ });
+ });
+});

0 comments on commit bcb5e36

Please sign in to comment.
Something went wrong with that request. Please try again.