mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-01-13 07:01:20 +08:00
test for Account.search
This commit is contained in:
@@ -147,7 +147,7 @@ Account.statics.search = (stuff, callback) ->
|
||||
if account
|
||||
return callback account
|
||||
|
||||
exports.findById stuff, (err, account) ->
|
||||
@findById stuff, (err, account) ->
|
||||
callback account
|
||||
|
||||
_.extend app.models,
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
utils = null
|
||||
Account = null
|
||||
|
||||
test_account = null
|
||||
created_account_ids = []
|
||||
|
||||
describe 'model/account', ->
|
||||
before ->
|
||||
require '../../../app'
|
||||
{utils} = app
|
||||
{Account} = app.models
|
||||
|
||||
after (done) ->
|
||||
Account.remove
|
||||
_id:
|
||||
$in: created_account_ids
|
||||
, done
|
||||
|
||||
describe 'validators should be work', ->
|
||||
it 'invalid_email', (done) ->
|
||||
account = new Account
|
||||
@@ -43,4 +52,28 @@ describe 'model/account', ->
|
||||
account.email.should.be.equal email.toLowerCase()
|
||||
account.password.should.have.length 64
|
||||
|
||||
created_account_ids.push account._id
|
||||
test_account = account
|
||||
|
||||
done()
|
||||
|
||||
describe 'search', ->
|
||||
it 'should work with username', (done) ->
|
||||
Account.search test_account.username, (result) ->
|
||||
result.email.should.be.equal test_account.email
|
||||
done()
|
||||
|
||||
it 'should work with email', (done) ->
|
||||
Account.search test_account.email, (result) ->
|
||||
result.username.should.be.equal test_account.username
|
||||
done()
|
||||
|
||||
it 'should work with id', (done) ->
|
||||
Account.search test_account.id, (result) ->
|
||||
result.username.should.be.equal test_account.username
|
||||
done()
|
||||
|
||||
it 'should not exist', (done) ->
|
||||
Account.search 'username_not_exist', (result) ->
|
||||
expect(result).to.not.exist
|
||||
done()
|
||||
|
||||
@@ -4,6 +4,7 @@ describe 'utils', ->
|
||||
describe 'rx', ->
|
||||
it 'username', ->
|
||||
utils.rx.username.test('jysperm').should.be.ok
|
||||
utils.rx.username.test('jy_sperm').should.be.ok
|
||||
utils.rx.username.test('JYSPERM').should.not.be.ok
|
||||
utils.rx.username.test('s').should.not.be.ok
|
||||
utils.rx.username.test('root-panel').should.not.be.ok
|
||||
|
||||
Reference in New Issue
Block a user