Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (30 sloc) 1.09 KB
chai = require('chai')
Word = require '../models/word'
sinon = require 'sinon'
chai.use require 'sinon-chai'
expect = chai.expect
EventEmitter = require('events').EventEmitter
events = new EventEmitter
describe 'Wordlist', ->
afterEach ->
it 'should exist', ->
expect(Word) 'function'
describe '#constructor', ->
it 'should throw if no word is provided in the hash', ->
expect(-> new Word).to.throw(Error, /A word must be provided/)
describe '.getWords', ->
it 'should emit a "wordsFetched" fetched with words instances', (done) ->
sinon.stub(Word._wordnik, 'randomWords').yields(null, [
{id: 1234, word: "hello"},
{id: 2345, word: "foo"},
{id: 3456, word: "goodbye"}
spy = sinon.spy()
Word.getWords (result) -> spy(result); done()
expect(spy).have.been.calledWith [
{id: 1234, word: "hello"},
{id: 2345, word: "foo"},
{id: 3456, word: "goodbye"}
Jump to Line
Something went wrong with that request. Please try again.