Permalink
Browse files

Add fetching collection from DB

  • Loading branch information...
smolak committed Dec 29, 2017
1 parent 72e5020 commit 03985f1d77bf34ed1b0bfd396cf3967fdd3fb6a2
Showing with 18 additions and 2 deletions.
  1. +3 −1 src/fetchHotelPhotos.js
  2. +15 −1 test/unit/src/fetchHotelPhotosSpec.js
View
@@ -1,3 +1,5 @@
export default function fetchHotelPhotos() {
export default function fetchHotelPhotos(dbClient, collectionName) {
dbClient.collection(collectionName); // (3)
return [ 'photo-1.jpg', 'photo-2.jpg', 'photo-3.jpg' ];
}
@@ -1,10 +1,24 @@
import { expect } from 'chai';
import sinon from 'sinon';
import fetchHotelPhotos from '../../../src/fetchHotelPhotos';
describe('fetchHotelPhotos', () => {
const connectedClientDouble = {
collection: sinon.spy()
};
const collectionName = 'hotels';
it('should fetch hotels collection from DB', () => {
fetchHotelPhotos(connectedClientDouble, collectionName);
expect(connectedClientDouble.collection)
.to.have.been.calledWithExactly('hotels') // (1)
.to.have.been.calledOnce;
});
it('should return hotel photos collection', () => {
const photosCollection = fetchHotelPhotos();
const photosCollection = fetchHotelPhotos(connectedClientDouble, collectionName); // (2)
expect(photosCollection).to.deep.equal([
'photo-1.jpg', 'photo-2.jpg', 'photo-3.jpg'

0 comments on commit 03985f1

Please sign in to comment.