Родитель
013f136add
Коммит
5d7cf079ea
|
@ -69,6 +69,65 @@ test(
|
|||
}
|
||||
)
|
||||
|
||||
test(
|
||||
'get account by uid',
|
||||
function (t) {
|
||||
t.plan(1)
|
||||
|
||||
var accountData
|
||||
var db
|
||||
|
||||
return dbConn
|
||||
.then(function (dbObj) {
|
||||
db = dbObj
|
||||
accountData = testHelpers.createTestAccount()
|
||||
|
||||
return db.pool.put(
|
||||
'/account/' + accountData.uid.toString('hex'),
|
||||
unbuffer(accountData)
|
||||
)
|
||||
})
|
||||
.then(function () {
|
||||
return db.account(accountData.uid)
|
||||
})
|
||||
.then(function (account) {
|
||||
t.false(account.emailVerified, false)
|
||||
t.end()
|
||||
}, function (err) {
|
||||
throw err
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
test(
|
||||
'throws db errors',
|
||||
function (t) {
|
||||
t.plan(2)
|
||||
var db
|
||||
|
||||
return dbConn
|
||||
.then(function (dbObj) {
|
||||
db = dbObj
|
||||
return db.emailRecord('unknownEmail@restmail.net')
|
||||
})
|
||||
.then(function () {
|
||||
t.notOk()
|
||||
}, function (err) {
|
||||
t.ok(err)
|
||||
return db.emailRecord('unknownEmail@restmail.net')
|
||||
|
||||
})
|
||||
.then(function () {
|
||||
t.notOk()
|
||||
}, function (err) {
|
||||
t.ok(err)
|
||||
t.end()
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
)
|
||||
|
||||
test(
|
||||
'teardown',
|
||||
function (t) {
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
var sinon = require('sinon')
|
||||
var tap = require('tap')
|
||||
var test = tap.test
|
||||
var legacyLog = require('../../legacy_log')
|
||||
|
||||
var spyLog = {
|
||||
critical: sinon.spy(),
|
||||
debug: sinon.spy(),
|
||||
error: sinon.spy(),
|
||||
info: sinon.spy(),
|
||||
warn: sinon.spy()
|
||||
}
|
||||
|
||||
test('legacy_log unit tests', function (t) {
|
||||
var data = {
|
||||
op: 'testOp',
|
||||
err: 'Nooo!'
|
||||
}
|
||||
var log = legacyLog(spyLog)
|
||||
log.trace(data)
|
||||
t.equal(spyLog.debug.args[0][0], data.op)
|
||||
t.equal(spyLog.debug.args[0][1], data)
|
||||
log.error(data)
|
||||
t.equal(spyLog.error.args[0][0], data.op)
|
||||
t.equal(spyLog.error.args[0][1], data)
|
||||
log.fatal(data)
|
||||
t.equal(spyLog.critical.args[0][0], data.op)
|
||||
t.equal(spyLog.critical.args[0][1], data)
|
||||
log.warn(data)
|
||||
t.equal(spyLog.warn.args[0][0], data.op)
|
||||
t.equal(spyLog.warn.args[0][1], data)
|
||||
log.info(data)
|
||||
t.equal(spyLog.info.args[0][0], data.op)
|
||||
t.equal(spyLog.info.args[0][1], data)
|
||||
t.done()
|
||||
})
|
|
@ -4,12 +4,14 @@
|
|||
|
||||
var extend = require('util')._extend
|
||||
|
||||
var sinon = require('sinon')
|
||||
var P = require('bluebird')
|
||||
var test = require('tap').test
|
||||
|
||||
var nullLog = {
|
||||
trace: function () {},
|
||||
info: function () {}
|
||||
info: function () {},
|
||||
error: function () {}
|
||||
}
|
||||
|
||||
var config = require('../../config')
|
||||
|
@ -525,5 +527,52 @@ P.all(
|
|||
}
|
||||
)
|
||||
|
||||
test(
|
||||
'resolves sendMail status',
|
||||
function (t) {
|
||||
var mailer = new Mailer(translator, templates, config.get('mail'))
|
||||
sinon.stub(mailer.mailer, 'sendMail', function (config, cb) {
|
||||
cb(null, { resp: 'ok' })
|
||||
})
|
||||
|
||||
var message = {
|
||||
email: 'test@restmail.net',
|
||||
subject: 'subject',
|
||||
template: 'suspiciousLocationEmail',
|
||||
uid: 'foo'
|
||||
}
|
||||
|
||||
return mailer.send(message)
|
||||
.then(function (status) {
|
||||
t.equal(status.resp, 'ok')
|
||||
t.done()
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
test(
|
||||
'rejects sendMail status',
|
||||
function (t) {
|
||||
var mailer = new Mailer(translator, templates, config.get('mail'))
|
||||
sinon.stub(mailer.mailer, 'sendMail', function (config, cb) {
|
||||
cb(new Error('Fail'))
|
||||
})
|
||||
|
||||
var message = {
|
||||
email: 'test@restmail.net',
|
||||
subject: 'subject',
|
||||
template: 'suspiciousLocationEmail',
|
||||
uid: 'foo'
|
||||
}
|
||||
|
||||
return mailer.send(message)
|
||||
.then(t.notOk, function (err) {
|
||||
t.equal(err.message, 'Fail')
|
||||
t.done()
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
}
|
||||
)
|
||||
|
|
Загрузка…
Ссылка в новой задаче