Last active
August 29, 2015 13:56
-
-
Save chmanie/8942216 to your computer and use it in GitHub Desktop.
yar_25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var expect = require('expect.js'); | |
var Hapi = require('hapi'); | |
var server = Hapi.createServer('0.0.0.0', 8080, { | |
debug: { | |
request: ['error'] | |
} | |
}); | |
var types = Hapi.types; | |
server.pack.require({ | |
yar: { | |
cookieOptions: { | |
password: 'temp', // cookie secret | |
isSecure: false // required for non-https applications | |
} | |
} | |
}, function (err) { | |
if (err) throw err; | |
}); | |
server.route({ | |
method: 'POST', | |
path: '/users', | |
config: { | |
validate: { | |
payload: { | |
password: types.String().min(8) | |
} | |
}, | |
handler: handler | |
} | |
}); | |
function handler(req, reply) { | |
reply('OK'); | |
} | |
describe('users resource controller', function () { | |
it('creates a user who has a password', function (done) { | |
server.inject({ method: 'POST', url: '/users', payload: | |
{ | |
password: 'secret' | |
} | |
}, function (res) { | |
expect(res.statusCode).to.equal(200); | |
done(); | |
} | |
); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment