0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-13 13:02:45 +00:00

Stubbing out tests for searching

This commit is contained in:
Scott Tolksdorf
2017-01-11 19:56:57 -08:00
parent dfcb04fd09
commit a405c7cfb2
2 changed files with 59 additions and 17 deletions

View File

@@ -93,7 +93,15 @@ const BrewData = {
return BrewData.get({ editId }); 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 //defaults with page and count
//returns a non-text version of brews //returns a non-text version of brews
//assume sanatized ? //assume sanatized ?

View File

@@ -16,25 +16,33 @@ const brews = {
title : 'BrewA', title : 'BrewA',
description : 'fancy', description : 'fancy',
authors : [], authors : [],
systems : [] systems : [],
views : 12,
published : true
}, },
BrewB : { BrewB : {
title : 'BrewB', title : 'BrewB',
description : 'fancy', description : 'fancy',
authors : [], authors : [],
systems : [] systems : [],
views : 7,
published : true
}, },
BrewC : { BrewC : {
title : 'BrewC', title : 'BrewC',
description : 'test', description : 'test',
authors : [], authors : [],
systems : [] systems : [],
views : 0,
published : false
}, },
BrewD : { BrewD : {
title : 'BrewD', title : 'BrewD',
description : 'test', description : 'test',
authors : [], authors : [],
systems : [] systems : [],
views : 1,
published : true
} }
}; };
@@ -48,22 +56,48 @@ describe('Brew Search', () => {
})); }));
}); });
describe('Searching', ()=>{
it('should be able to search for all brews', ()=>{
});
it('should find brews based on title and/or description', () => { 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');})
return BrewData.create({
text : 'Brew Text'
}).then((brew) => {
});
//result.count.should.be.equal(2) //result.count.should.be.equal(2)
//result.brews.should.deep.include.members(ids(['BrewA', 'BrewB']); //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', ()=>{
});
}); });