1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-20 21:01:30 +00:00

Upgrading the brew generation for testing

This commit is contained in:
Scott Tolksdorf
2017-01-27 10:47:38 -05:00
parent 8e58e5aca9
commit 8018442f25
2 changed files with 18 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
const testing = require('./test.init.js'); const Test = require('./test.init.js');
const _ = require('lodash'); const _ = require('lodash');
const DB = require('db.js'); const DB = require('db.js');
@@ -15,7 +15,7 @@ const ids = (brewIds) => {
//TODO: Move this brew generator to test.init //TODO: Move this brew generator to test.init
const brews = { const brews = {
BrewA : { BrewA : {
title : 'BrewA', title : 'Brew-Alpha',
description : 'fancy', description : 'fancy',
authors : ['userA'], authors : ['userA'],
systems : [], systems : [],
@@ -23,7 +23,7 @@ const brews = {
published : false published : false
}, },
BrewB : { BrewB : {
title : 'BrewB', title : 'Brew-Beta',
description : 'very fancy', description : 'very fancy',
authors : ['userA'], authors : ['userA'],
systems : [], systems : [],
@@ -31,7 +31,7 @@ const brews = {
published : true published : true
}, },
BrewC : { BrewC : {
title : 'BrewC', title : 'Brew-Charlie',
description : 'test', description : 'test',
authors : ['userA', 'userB'], authors : ['userA', 'userB'],
systems : [], systems : [],
@@ -39,7 +39,7 @@ const brews = {
published : false published : false
}, },
BrewD : { BrewD : {
title : 'BrewD', title : 'Brew-Delta',
description : 'test super amazing brew for 5e. Geared for Rangers.', description : 'test super amazing brew for 5e. Geared for Rangers.',
authors : ['userC'], authors : ['userC'],
systems : [], systems : [],
@@ -119,7 +119,7 @@ describe('Brew Search', () => {
describe('Term Search', ()=>{ describe('Term Search', ()=>{
it('should search brews based on title', () => { it('should search brews based on title', () => {
return BrewData.termSearch('BrewC') return BrewData.termSearch('Charlie')
.then((result) => { .then((result) => {
result.total.should.be.equal(1); result.total.should.be.equal(1);
result.brews.should.containSubset(ids(['BrewC'])); result.brews.should.containSubset(ids(['BrewC']));
@@ -143,19 +143,22 @@ describe('Brew Search', () => {
}); });
it('should perform an AND operation on the provided terms', () => { it('should perform an AND operation on the provided terms', () => {
return BrewData.termSearch('BrewD GARBAGE') return BrewData.termSearch('Brew Delta GARBAGE')
.then((result) => { .then((result) => {
result.total.should.be.equal(0); result.total.should.be.equal(0);
}); });
}); });
it('should search brews based on a combination of both', () => { it('should search brews based on a combination of both', () => {
return BrewData.termSearch('BrewB fancy') return BrewData.termSearch('Brew Beta fancy')
.then((result) => { .then((result) => {
result.total.should.be.equal(1); result.total.should.be.equal(1);
result.brews.should.containSubset(ids(['BrewB'])); result.brews.should.containSubset(ids(['BrewB']));
}); });
}); });
it.skip('should not worry about the case of the terms', () => {
});
}); });
describe('User Search', ()=>{ describe('User Search', ()=>{

View File

@@ -7,14 +7,17 @@ const config = require('nconf')
.file('environment', { file: `config/${process.env.NODE_ENV}.json` }) .file('environment', { file: `config/${process.env.NODE_ENV}.json` })
.file('defaults', { file: 'config/default.json' }); .file('defaults', { file: 'config/default.json' });
const should = require('chai') const Chai = require('chai')
.use(require('chai-as-promised')) .use(require('chai-as-promised'))
.use(require('chai-subset')) .use(require('chai-subset'));
.should();
const log = require('loglevel'); const log = require('loglevel');
log.setLevel(config.get('log_level')); log.setLevel(config.get('log_level'));
//TODO: extend should to have a brewCheck
// eg. result.brews.should.haveBrews('BrewA', 'BrewB')
// Then can remove chai-subset
module.exports = { module.exports = {
should: should should: Chai.should()
}; };