From a405c7cfb21d303125f5318f830c36b87cf8d42e Mon Sep 17 00:00:00 2001 From: Scott Tolksdorf Date: Wed, 11 Jan 2017 19:56:57 -0800 Subject: [PATCH] Stubbing out tests for searching --- server/brew.data.js | 10 ++++++- test/search.test.js | 66 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 59 insertions(+), 17 deletions(-) diff --git a/server/brew.data.js b/server/brew.data.js index 367d33b..217c8cf 100644 --- a/server/brew.data.js +++ b/server/brew.data.js @@ -93,7 +93,15 @@ const BrewData = { return BrewData.get({ editId }); }, - search : (query, req={}) => { + search : (query, pagniation, sorting, permissions) => { + + + //search with query, add in `published = false` + // filter out editId and text + + //if admin, removed published=false, remove filtering editId + + //defaults with page and count //returns a non-text version of brews //assume sanatized ? diff --git a/test/search.test.js b/test/search.test.js index c4ab4e0..091f2df 100644 --- a/test/search.test.js +++ b/test/search.test.js @@ -16,25 +16,33 @@ const brews = { title : 'BrewA', description : 'fancy', authors : [], - systems : [] + systems : [], + views : 12, + published : true }, BrewB : { title : 'BrewB', description : 'fancy', authors : [], - systems : [] + systems : [], + views : 7, + published : true }, BrewC : { title : 'BrewC', description : 'test', authors : [], - systems : [] + systems : [], + views : 0, + published : false }, BrewD : { title : 'BrewD', description : 'test', authors : [], - systems : [] + systems : [], + views : 1, + published : true } }; @@ -48,21 +56,47 @@ describe('Brew Search', () => { })); }); - it('should find brews based on title and/or description', () => { - return new Promise((resolve, reject) => { - return reject() - }) - .catch(()=>{ console.log('here1');}) - .catch(()=>{ console.log('here2');}) + describe('Searching', ()=>{ + it('should be able to search for all brews', ()=>{ - return BrewData.create({ - text : 'Brew Text' - }).then((brew) => { -}); - //result.count.should.be.equal(2) - //result.brews.should.deep.include.members(ids(['BrewA', 'BrewB']); + }); + it('should find brews based on title and/or description', () => { + + //result.count.should.be.equal(2) + //result.brews.should.deep.include.members(ids(['BrewA', 'BrewB']); + }); + + it('should return the total number of brews and page info for query', ()=>{ + + }); + }) + + describe('Permissions', () => { + it('should only fetch published brews', () => { + + }); + it('fetched brews should not have text or editId', () => { + + }); + it('if admin, fetches also non-published brews, with editid', () => { + + }); + it('if author, fetches also non-published brews, with editid', ()=>{ + + }); + }); + + describe('Pagniation', () => { + it('should return the exact number of brews based on limit', () => { + + }); + + }); + + desscribe('Sorting', ()=>{ + });