Skip to content

Commit

Permalink
test: adaptions for @hoodie/account-server@6
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Oct 30, 2016
1 parent a449032 commit b9cd92b
Showing 1 changed file with 3 additions and 32 deletions.
35 changes: 3 additions & 32 deletions test/unit/config/account-test.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,24 @@
var simple = require('simple-mock')
var test = require('tap').test

var accountConfig = require('../../../lib/config/account')

test('account config', function (t) {
var dbStub = {
installUsersBehavior: simple.stub().resolveWith()
}
var PouchDBMock = simple.stub().returnWith(dbStub)
simple.mock(PouchDBMock, 'plugin').returnWith()

accountConfig({
db: {
admins: 'db admins',
secret: 'db secret'
},
config: {
PouchDB: PouchDBMock,
PouchDB: 'PouchDB',
account: {}
}
}, function (error, config) {
t.error(error)

t.is(config.account.admins, 'db admins', 'sets config.account.admins')
t.is(config.account.secret, 'db secret', 'sets config.account.secret')
t.same(config.account.usersDb, dbStub, 'sets config.account.usersDb')

t.end()
})
})

test('account config installUsersBehavior error handling', function (t) {
var dbStub = {
installUsersBehavior: simple.stub().rejectWith(new Error('ooops'))
}
var PouchDBMock = simple.stub().returnWith(dbStub)
simple.mock(PouchDBMock, 'plugin').returnWith()
accountConfig({
db: {
admins: 'db admins',
secret: 'db secret'
},
config: {
PouchDB: PouchDBMock,
account: {}
}
}, function (error, config) {
t.ok(error)
t.is(error.message, 'ooops')
t.is(config.account.usersDb, '_users', 'sets config.account.usersDb')
t.is(config.account.PouchDB, 'PouchDB', 'sets config.account.PouchDB')

t.end()
})
Expand Down

0 comments on commit b9cd92b

Please sign in to comment.