Created
June 26, 2011 19:10
-
-
Save roykolak/1047872 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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