Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Commit

Permalink
improved code coverage, cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-aladev committed Jul 22, 2016
1 parent 96fceb7 commit eafb5b4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions sample/routes/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ router.get('/', function (req, res, next) {
});

router.post('/', function (req, res, next) {
if (! req.body.doc) {
if (!req.body.doc) {
debug('invalid request on post - missing doc');
return res.status(400).send ({ error: 'invalid request - missing doc'});
}

if (! req.body.secret) {
if (!req.body.secret) {
debug('no secret provided - continuing...');
}

Expand Down
4 changes: 2 additions & 2 deletions sample/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ webServer.listen(webAppPort, function () {
});
webServer.on('error', onError);

// prefix dir should exist.
// prefix dir should exist.
var prefixDir = './db';
if (! fs.existsSync(prefixDir)){
if (!fs.existsSync(prefixDir)){
fs.mkdirSync(prefixDir);
}
var pbsetup = PouchDB.defaults({ prefix: prefixDir + '/' });
Expand Down
12 changes: 7 additions & 5 deletions test/test-thali-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('We are validating requests that look like /db/_local/thali_:ID', funct
//Norml middleware usage..0
var acl = require('./acl-block.1.js');
router.all('*', lib('foobar', acl, verifyThaliUser));
//mock handlers
//mock handlers
app.use('/', genericHandlers(router, pathWithId));
})

Expand All @@ -57,16 +57,18 @@ describe('We are validating requests that look like /db/_local/thali_:ID', funct
.set('Accept', 'application/json')
.expect(200, done);
})

//
it('GET should fail as it does not match valid ID ' + rootPath + 'zzz', function(done) {
request(app)
.get(rootPath + 'zzz')
.set('Accept', 'application/json')
.expect(401, done);
})


it('GET should fail as it does not match valid ID ' + rootPath, function(done) {
request(app)
.get(rootPath)
.set('Accept', 'application/json')
.expect(401, done);
})
it('PUT should be OK - we are using ' + validId, function(done) {
request(app)
.put(pathWithId)
Expand Down

0 comments on commit eafb5b4

Please sign in to comment.