diff --git a/test/api/v3/integration/hall/GET-hall_heroes_heroId.test.js b/test/api/v3/integration/hall/GET-hall_heroes_heroId.test.js index 390f92514a..6619e83fd9 100644 --- a/test/api/v3/integration/hall/GET-hall_heroes_heroId.test.js +++ b/test/api/v3/integration/hall/GET-hall_heroes_heroId.test.js @@ -54,7 +54,7 @@ describe('GET /heroes/:heroId', () => { 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({ contributor: {tier: 23}, }); @@ -68,15 +68,9 @@ describe('GET /heroes/:heroId', () => { expect(heroRes.profile).to.have.all.keys(['name']); }); - it('returns hero data given username without case sensitivity', async () => { - let hero = await generateUser({}, 'TestUpperCaseName123'); - let heroRes = await user.get(`/hall/heroes/${hero.auth.local.username.toLowerCase()}`); - - 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']); + it('returns correct hero using search with difference case', async () => { + let hero = await generateUser({}, { username: 'TestUpperCaseName123' }); + let heroRes = await user.get(`/hall/heroes/TestuPPerCasEName123`); + expect(heroRes.auth.local.username).to.equal('TestUpperCaseName123'); }); }); diff --git a/test/helpers/api-integration/v3/object-generators.js b/test/helpers/api-integration/v3/object-generators.js index 00ef85a955..403df7710a 100644 --- a/test/helpers/api-integration/v3/object-generators.js +++ b/test/helpers/api-integration/v3/object-generators.js @@ -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: // { 'items.eggs.Wolf': 10 } // -// To manually set a username pass it as the second parameter. -// If no password is passed or it is falsy then a username will -// be auto-generated. -// Example: generateUser({}, 'TestName') adds user with the 'TestName' username. -export async function generateUser (update = {}, manualUsername = null) { - let username = manualUsername || (Date.now() + generateUUID()).substring(0, 20); - let password = 'password'; - let email = `${username}@example.com`; +// To manually set a username, email or password pass it in as +// an object for the second parameter. Only overrides need to be +// added. Items that don't exist will be autogenerated. +// Example: generateUser({}, { username: 'TestName' }) adds user +// with the 'TestName' username. +export async function generateUser (update = {}, overrides = {}) { + let username = overrides.username || (Date.now() + generateUUID()).substring(0, 20); + let password = overrides.password || 'password'; + let email = overrides.email || `${username}@example.com`; let user = await requester().post('/user/auth/local/register', { username,