Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Commands tests.

  • Loading branch information...
commit 0cc4a07a15c614988756a222bce92fe5b1c2dc55 1 parent 1a5451b
@vesln authored
Showing with 47 additions and 2 deletions.
  1. +47 −2 test/commands.test.js
View
49 test/commands.test.js
@@ -4,11 +4,16 @@
* Veselin Todorov <hi@vesln.com>
* MIT License.
*/
+
+/**
+ * Module dependencies.
+ */
+var sinon = require('sinon');
/**
* Support.
*/
-var storage = require('../storage');
+var storage = require('../lib/storage');
/**
* The tests object.
@@ -26,7 +31,47 @@ describe('commands', function() {
describe('.delete()', function() {
it('should call storage.delete and storage.save', function() {
-
+ sinon.spy(storage, 'del');
+ sinon.stub(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();
+ });
+ });
+
+ describe('.get()', function() {
+ it('should call storage.get', function() {
+ sinon.stub(storage, 'get');
+ commands.get('foo');
+ storage.get.getCall(0).args[0].should.eql('foo');
+ storage.get.calledOnce.should.be.ok;
+ storage.get.restore();
+ });
+ });
+
+ describe('.set()', function() {
+ it('should call storage.set and storage.save', function() {
+ sinon.spy(storage, 'set');
+ sinon.stub(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();
+ });
+ });
+
+ describe('.list()', function() {
+ it('should call storage.get with no params', function() {
+ sinon.stub(storage, 'get');
+ commands.get('foo');
+ storage.get.calledOnce.should.be.ok;
+ storage.get.restore();
});
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.