Permalink
Browse files

Test refactoring.

  • Loading branch information...
1 parent 256bf2c commit 11b3a2cfb696c8a31bf62f84cfb80c69c584a9ea @vesln committed Jan 28, 2012
Showing with 24 additions and 28 deletions.
  1. +24 −28 test/commands.test.js
View
@@ -9,18 +9,14 @@
* Module dependencies.
*/
var sinon = require('sinon');
-
-/**
- * Support.
- */
-var storage = require('../lib/storage');
+var clone = require('super');
/**
* The tests object.
*
* @type {Object}
*/
-var commands = require('../lib/commands');
+var commands = clone(require('../lib/commands'), {});
describe('commands', function() {
describe('.version()', function() {
@@ -31,47 +27,47 @@ describe('commands', function() {
describe('.delete()', function() {
it('should call storage.delete and storage.save', function() {
- sinon.spy(storage, 'del');
- sinon.stub(storage, 'save');
+ sinon.spy(commands.storage, 'del');
+ sinon.stub(commands.storage, 'save');
commands.delete('foo');
- storage.del.calledOnce.should.be.ok;
- storage.del.getCall(0).args[0].should.eql('foo');
- storage.save.calledOnce.should.be.ok;
- storage.del.restore();
- storage.save.restore();
+ commands.storage.del.calledOnce.should.be.ok;
+ commands.storage.del.getCall(0).args[0].should.eql('foo');
+ commands.storage.save.calledOnce.should.be.ok;
+ commands.storage.del.restore();
+ commands.storage.save.restore();
});
});
describe('.get()', function() {
it('should call storage.get', function() {
- sinon.stub(storage, 'get');
+ sinon.stub(commands.storage, 'get');
commands.get('foo');
- storage.get.getCall(0).args[0].should.eql('foo');
- storage.get.calledOnce.should.be.ok;
- storage.get.restore();
+ commands.storage.get.getCall(0).args[0].should.eql('foo');
+ commands.storage.get.calledOnce.should.be.ok;
+ commands.storage.get.restore();
});
});
describe('.set()', function() {
it('should call storage.set and storage.save', function() {
- sinon.spy(storage, 'set');
- sinon.stub(storage, 'save');
+ sinon.spy(commands.storage, 'set');
+ sinon.stub(commands.storage, 'save');
commands.set('foo', 'bar');
- storage.set.calledOnce.should.be.ok;
- storage.set.getCall(0).args[0].should.eql('foo');
- storage.set.getCall(0).args[1].should.eql('bar');
- storage.save.calledOnce.should.be.ok;
- storage.set.restore();
- storage.save.restore();
+ commands.storage.set.calledOnce.should.be.ok;
+ commands.storage.set.getCall(0).args[0].should.eql('foo');
+ commands.storage.set.getCall(0).args[1].should.eql('bar');
+ commands.storage.save.calledOnce.should.be.ok;
+ commands.storage.set.restore();
+ commands.storage.save.restore();
});
});
describe('.list()', function() {
it('should call storage.get with no params', function() {
- sinon.stub(storage, 'get');
+ sinon.stub(commands.storage, 'get');
commands.get('foo');
- storage.get.calledOnce.should.be.ok;
- storage.get.restore();
+ commands.storage.get.calledOnce.should.be.ok;
+ commands.storage.get.restore();
});
});
});

0 comments on commit 11b3a2c

Please sign in to comment.