mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
lint: Fix linting errors in api v2 tests
This commit is contained in:
@@ -4,80 +4,77 @@ import {
|
||||
import { each } from 'lodash';
|
||||
|
||||
describe('GET /user/anonymized', () => {
|
||||
let user;
|
||||
let user, anonymizedUser;
|
||||
|
||||
before(async () => {
|
||||
return generateUser({
|
||||
'inbox.messages' : {
|
||||
'the-message-id' : {
|
||||
sort : 214,
|
||||
user : 'Some user',
|
||||
backer : {},
|
||||
contributor : {
|
||||
text : 'Blacksmith',
|
||||
level : 2,
|
||||
contributions : 'Made some contributions',
|
||||
admin : false
|
||||
user = await generateUser({
|
||||
'inbox.messages': {
|
||||
'the-message-id': {
|
||||
sort: 214,
|
||||
user: 'Some user',
|
||||
backer: {},
|
||||
contributor: {
|
||||
text: 'Blacksmith',
|
||||
level: 2,
|
||||
contributions: 'Made some contributions',
|
||||
admin: false,
|
||||
},
|
||||
uuid : 'some-users-uuid',
|
||||
flagCount : 0,
|
||||
flags : {},
|
||||
likes : {},
|
||||
timestamp : 1444154258699.0000000000000000,
|
||||
text : 'Lorem ipsum',
|
||||
id : 'the-messages-id',
|
||||
sent : true
|
||||
}
|
||||
}
|
||||
}).then((usr) => {
|
||||
user = usr;
|
||||
return user.post('/user/tasks', {
|
||||
text: 'some private text',
|
||||
notes: 'some private notes',
|
||||
checklist: [
|
||||
{text: 'a private checklist'},
|
||||
{text: 'another private checklist'},
|
||||
],
|
||||
type: 'daily',
|
||||
});
|
||||
}).then((result) => {
|
||||
return user.get('/user/anonymized');
|
||||
}).then((anonymizedUser) => {
|
||||
user = anonymizedUser;
|
||||
uuid: 'some-users-uuid',
|
||||
flagCount: 0,
|
||||
flags: {},
|
||||
likes: {},
|
||||
timestamp: 1444154258699.0000000000000000,
|
||||
text: 'Lorem ipsum',
|
||||
id: 'the-messages-id',
|
||||
sent: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await user.post('/user/tasks', {
|
||||
text: 'some private text',
|
||||
notes: 'some private notes',
|
||||
checklist: [
|
||||
{text: 'a private checklist'},
|
||||
{text: 'another private checklist'},
|
||||
],
|
||||
type: 'daily',
|
||||
});
|
||||
|
||||
anonymizedUser = await user.get('/user/anonymized');
|
||||
});
|
||||
|
||||
it('retains user id', async () => {
|
||||
expect(user._id).to.exist;
|
||||
expect(anonymizedUser._id).to.eql(user._id);
|
||||
});
|
||||
|
||||
it('removes credentials and financial information', async () => {
|
||||
expect(user.apiToken).to.not.exist;
|
||||
expect(user.auth.local).to.not.exist;
|
||||
expect(user.auth.facebook).to.not.exist;
|
||||
expect(user.purchased.plan).to.not.exist;
|
||||
expect(anonymizedUser.apiToken).to.not.exist;
|
||||
expect(anonymizedUser.auth.local).to.not.exist;
|
||||
expect(anonymizedUser.auth.facebook).to.not.exist;
|
||||
expect(anonymizedUser.purchased.plan).to.not.exist;
|
||||
});
|
||||
|
||||
it('removes profile information', async () => {
|
||||
expect(user.profile).to.not.exist;
|
||||
expect(user.contributor).to.not.exist;
|
||||
expect(user.achievements.challenges).to.not.exist;
|
||||
expect(anonymizedUser.profile).to.not.exist;
|
||||
expect(anonymizedUser.contributor).to.not.exist;
|
||||
expect(anonymizedUser.achievements.challenges).to.not.exist;
|
||||
});
|
||||
|
||||
it('removes social information', async () => {
|
||||
expect(user.newMessages).to.not.exist;
|
||||
expect(user.invitations).to.not.exist;
|
||||
expect(user.items.special.nyeReceived).to.not.exist;
|
||||
expect(user.items.special.valentineReceived).to.not.exist;
|
||||
expect(anonymizedUser.newMessages).to.not.exist;
|
||||
expect(anonymizedUser.invitations).to.not.exist;
|
||||
expect(anonymizedUser.items.special.nyeReceived).to.not.exist;
|
||||
expect(anonymizedUser.items.special.valentineReceived).to.not.exist;
|
||||
|
||||
each(user.inbox.messages, (msg) => {
|
||||
each(anonymizedUser.inbox.messages, (msg) => {
|
||||
expect(msg.text).to.eql('inbox message text');
|
||||
});
|
||||
});
|
||||
|
||||
it('anonymizes task info', async () => {
|
||||
each(['habits', 'todos', 'dailys', 'rewards'], (tasks) => {
|
||||
each(user[tasks], (task) => {
|
||||
each(anonymizedUser[tasks], (task) => {
|
||||
expect(task.text).to.eql('task text');
|
||||
expect(task.notes).to.eql('task notes');
|
||||
|
||||
@@ -89,13 +86,13 @@ describe('GET /user/anonymized', () => {
|
||||
});
|
||||
|
||||
it('anonymizes tags', async () => {
|
||||
each(user.tags, (tag) => {
|
||||
each(anonymizedUser.tags, (tag) => {
|
||||
expect(tag.name).to.eql('tag');
|
||||
expect(tag.challenge).to.eql('challenge');
|
||||
});
|
||||
});
|
||||
|
||||
it('removes webhooks', async () => {
|
||||
expect(user.webhooks).to.not.exist;
|
||||
expect(anonymizedUser.webhooks).to.not.exist;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user