Skip to content

Instantly share code, notes, and snippets.

@roykolak
Created June 26, 2011 19:10
Show Gist options
  • Save roykolak/1047872 to your computer and use it in GitHub Desktop.
Save roykolak/1047872 to your computer and use it in GitHub Desktop.
require('../lib/store.js');
describe('Store', function() {
var store, results, buddy, callback;
beforeEach(function() {
callback = jasmine.createSpy('callback');
results = 'fake results';
buddy = '805-769-8255';
store = new Store({});
spyOn(store, 'run').andCallFake(function(method, params, callback) {
callback(results);
});
});
describe('#addBuddyWaiting', function() {
it('adds the passed buddy to the waiting buddies queue', function() {
store.addBuddyWaiting(buddy, callback);
expect(store.run).toHaveBeenCalledWith('rpush', ['buddies', buddy], jasmine.any(Function));
});
it('calls the passed callback with the results', function() {
store.addBuddyWaiting(buddy, callback);
expect(callback).toHaveBeenCalledWith(results);
});
});
describe('#getBuddiesWaiting', function() {
it('returns all the buddies in the waiting queue', function() {
store.getBuddiesWaiting(callback);
expect(store.run).toHaveBeenCalledWith('lrange', ['buddies', 0, -1], jasmine.any(Function));
});
it('calls the passed callback with the results', function() {
store.getBuddiesWaiting(callback);
expect(callback).toHaveBeenCalledWith(results);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment