meshblu-core-datastore
Version:
33 lines (25 loc) • 869 B
text/coffeescript
{describe,beforeEach,it,expect} = global
mongojs = require 'mongojs'
Datastore = require '../src/datastore'
describe 'Datastore cache stuff', ->
beforeEach ->
= new Datastore
database: mongojs('datastore-test')
collection: 'jalapenos'
cacheAttributes: ['id', 'jalapId']
describe '->_generateCacheKey', ->
describe 'when the fields exist', ->
beforeEach ->
query =
id: 'foo'
jalapId: 'serano'
= ._generateCacheKey {query}
it 'should generate the proper key', ->
expect().to.equal '71e52b62d7f35e138983163d679121b5e5123f4d'
describe 'when a field is missing', ->
beforeEach ->
query =
id: 'foo'
= ._generateCacheKey {query}
it 'should return null', ->
expect().to.be.undefined