mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
Overrides for generateUser and test adjustment
This commit is contained in:
@@ -54,7 +54,7 @@ describe('GET /heroes/:heroId', () => {
|
|||||||
expect(heroRes.profile).to.have.all.keys(['name']);
|
expect(heroRes.profile).to.have.all.keys(['name']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns only necessary hero data given username with display case', async () => {
|
it('returns only necessary hero data given username', async () => {
|
||||||
let hero = await generateUser({
|
let hero = await generateUser({
|
||||||
contributor: {tier: 23},
|
contributor: {tier: 23},
|
||||||
});
|
});
|
||||||
@@ -68,15 +68,9 @@ describe('GET /heroes/:heroId', () => {
|
|||||||
expect(heroRes.profile).to.have.all.keys(['name']);
|
expect(heroRes.profile).to.have.all.keys(['name']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns hero data given username without case sensitivity', async () => {
|
it('returns correct hero using search with difference case', async () => {
|
||||||
let hero = await generateUser({}, 'TestUpperCaseName123');
|
let hero = await generateUser({}, { username: 'TestUpperCaseName123' });
|
||||||
let heroRes = await user.get(`/hall/heroes/${hero.auth.local.username.toLowerCase()}`);
|
let heroRes = await user.get(`/hall/heroes/TestuPPerCasEName123`);
|
||||||
|
expect(heroRes.auth.local.username).to.equal('TestUpperCaseName123');
|
||||||
expect(heroRes).to.have.all.keys([
|
|
||||||
'_id', 'id', 'balance', 'profile', 'purchased',
|
|
||||||
'contributor', 'auth', 'items',
|
|
||||||
]);
|
|
||||||
expect(heroRes.auth.local).not.to.have.keys(['salt', 'hashed_password']);
|
|
||||||
expect(heroRes.profile).to.have.all.keys(['name']);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,14 +14,15 @@ import * as Tasks from '../../../../website/server/models/task';
|
|||||||
// , you can do so by passing in the full path as a string:
|
// , you can do so by passing in the full path as a string:
|
||||||
// { 'items.eggs.Wolf': 10 }
|
// { 'items.eggs.Wolf': 10 }
|
||||||
//
|
//
|
||||||
// To manually set a username pass it as the second parameter.
|
// To manually set a username, email or password pass it in as
|
||||||
// If no password is passed or it is falsy then a username will
|
// an object for the second parameter. Only overrides need to be
|
||||||
// be auto-generated.
|
// added. Items that don't exist will be autogenerated.
|
||||||
// Example: generateUser({}, 'TestName') adds user with the 'TestName' username.
|
// Example: generateUser({}, { username: 'TestName' }) adds user
|
||||||
export async function generateUser (update = {}, manualUsername = null) {
|
// with the 'TestName' username.
|
||||||
let username = manualUsername || (Date.now() + generateUUID()).substring(0, 20);
|
export async function generateUser (update = {}, overrides = {}) {
|
||||||
let password = 'password';
|
let username = overrides.username || (Date.now() + generateUUID()).substring(0, 20);
|
||||||
let email = `${username}@example.com`;
|
let password = overrides.password || 'password';
|
||||||
|
let email = overrides.email || `${username}@example.com`;
|
||||||
|
|
||||||
let user = await requester().post('/user/auth/local/register', {
|
let user = await requester().post('/user/auth/local/register', {
|
||||||
username,
|
username,
|
||||||
|
|||||||
Reference in New Issue
Block a user