mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
34 lines
918 B
JavaScript
34 lines
918 B
JavaScript
import { model as User } from '../../../../../website/src/models/user';
|
|
|
|
describe('User Model', () => {
|
|
it('keeps user._tmp when calling .toJSON', () => {
|
|
let user = new User({
|
|
auth: {
|
|
local: {
|
|
username: 'username',
|
|
lowerCaseUsername: 'username',
|
|
email: 'email@email.email',
|
|
salt: 'salt',
|
|
hashed_password: 'hashed_password', // eslint-disable-line camelcase
|
|
},
|
|
},
|
|
});
|
|
|
|
user._tmp = {ok: true};
|
|
user._nonTmp = {ok: true};
|
|
|
|
expect(user._tmp).to.eql({ok: true});
|
|
expect(user._nonTmp).to.eql({ok: true});
|
|
|
|
let toObject = user.toObject();
|
|
let toJSON = user.toJSON();
|
|
|
|
expect(toObject).to.not.have.keys('_tmp');
|
|
expect(toObject).to.not.have.keys('_nonTmp');
|
|
|
|
expect(toJSON).to.have.any.key('_tmp');
|
|
expect(toJSON._tmp).to.eql({ok: true});
|
|
expect(toJSON).to.not.have.keys('_nonTmp');
|
|
});
|
|
});
|