habitica/test/api/user/GET-user.test.js

34 lines
807 B
JavaScript
Raw Normal View History

2015-10-17 23:27:19 +00:00
import {
generateUser,
requester,
} from '../../helpers/api.helper';
describe('GET /user', () => {
2015-10-25 13:14:16 +00:00
let user;
2015-10-17 23:27:19 +00:00
2015-10-29 02:06:28 +00:00
before(() => {
2015-10-25 13:14:16 +00:00
return generateUser().then((usr) => {
2015-10-29 02:06:28 +00:00
let api = requester(usr);
return api.get('/user');
}).then((fetchedUser) => {
user = fetchedUser;
2015-10-25 13:14:16 +00:00
});
2015-10-17 23:27:19 +00:00
});
it('gets the user object', () => {
2015-10-29 02:06:28 +00:00
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
2015-10-17 23:27:19 +00:00
});
});