Permalink
Browse files

Using colors instead of color. + tests

  • Loading branch information...
1 parent 47567f3 commit 5c44ca8f50d35bd675ded977f7b41b2775af789e @vesln committed Jan 29, 2012
Showing with 31 additions and 6 deletions.
  1. +5 −5 lib/formatter.js
  2. +1 −1 package.json
  3. +25 −0 test/formatter.test.js
View
@@ -8,7 +8,7 @@
/**
* Module dependencies.
*/
-var color = require('color');
+var colors = require('colors');
/**
* Formatter namespace.
@@ -26,10 +26,10 @@ var formatter = module.exports;
* @api public
*/
formatter.format = function(item, num) {
- var state = item.done ? ''.green : ''.red ;
+ var state = (item.done) ? ''.green : ''.red;
- return ' '
- + '#' + num + ' '
- + state + ' '
+ return ' '
+ + '#' + num + ' '
+ + state + ' '
+ item.text;
};
View
@@ -7,7 +7,7 @@
, "dependencies": {
"flatiron": "~0.1.7"
, "storr": "0.0.1"
- , "color": "0.4.1"
+ , "colors": "0.6.0-1"
}
, "devDependencies": {
"mocha": "0.3.3"
@@ -0,0 +1,25 @@
+/*!
+ * todo - Todos in the CLI like what.
+ *
+ * Veselin Todorov <hi@vesln.com>
+ * MIT License.
+ */
+
+/**
+ * The tests object.
+ *
+ * @type {Object}
+ */
+var formatter = require('../lib/formatter');
+
+describe('formatter', function() {
+ describe('.format()', function() {
+ it('should format done items properly', function() {
+ formatter.format({ text: 'Foo', done: true }, 1).should.eql(' #1 \u001b[32m√\u001b[39m Foo');
+ });
+
+ it('should format unfinished items properly', function() {
+ formatter.format({ text: 'Foo', done: false }, 1).should.eql(' #1 \u001b[31m✖\u001b[39m Foo');
+ });
+ });
+});

0 comments on commit 5c44ca8

Please sign in to comment.