mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Move get user tests
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
require('../../website/src/server')
|
||||
|
||||
describe 'User', ->
|
||||
|
||||
before (done) ->
|
||||
registerNewUser done, true
|
||||
|
||||
describe 'GET /user', ->
|
||||
it 'removes password from user object', (done) ->
|
||||
request.get(baseURL + '/user')
|
||||
.end (err, res) ->
|
||||
expectCode res, 200
|
||||
localAuth = res.body.auth.local
|
||||
expect(localAuth.hashed_password).to.not.exist
|
||||
expect(localAuth.salt).to.not.exist
|
||||
done()
|
||||
|
||||
it 'removes apiToken from user object', (done) ->
|
||||
request.get(baseURL + '/user')
|
||||
.end (err, res) ->
|
||||
expectCode res, 200
|
||||
expect(res.body.apiToken).to.not.exist
|
||||
done()
|
||||
@@ -6,19 +6,28 @@ import {
|
||||
describe('GET /user', () => {
|
||||
let user;
|
||||
|
||||
beforeEach(() => {
|
||||
before(() => {
|
||||
return generateUser().then((usr) => {
|
||||
user = usr;
|
||||
let api = requester(usr);
|
||||
return api.get('/user');
|
||||
}).then((fetchedUser) => {
|
||||
user = fetchedUser;
|
||||
});
|
||||
});
|
||||
|
||||
it('gets the user object', () => {
|
||||
let api = requester(user);
|
||||
return api.get('/user').then((fetchedUser) => {
|
||||
expect(fetchedUser._id).to.eql(user._id);
|
||||
expect(fetchedUser.auth.local.username).to.eql(user.auth.local.username);
|
||||
expect(fetchedUser.todos).to.eql(user.todos);
|
||||
expect(fetchedUser.items).to.eql(user.items);
|
||||
});
|
||||
expect(user._id).to.eql(user._id);
|
||||
expect(user.auth.local.username).to.eql(user.auth.local.username);
|
||||
expect(user.todos).to.eql(user.todos);
|
||||
expect(user.items).to.eql(user.items);
|
||||
});
|
||||
|
||||
it('does not include password information', () => {
|
||||
expect(user.auth.local.hashed_password).to.not.exist
|
||||
expect(user.auth.local.salt).to.not.exist
|
||||
});
|
||||
|
||||
it('does not include api token', () => {
|
||||
expect(user.apiToken).to.not.exist
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user