mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
tests(api): Convert tests to use new api user methods
This commit is contained in:
@@ -2,14 +2,13 @@ import {
|
||||
generateGroup,
|
||||
generateUser,
|
||||
resetHabiticaDB,
|
||||
requester,
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
|
||||
describe('GET /groups', () => {
|
||||
const NUMBER_OF_PUBLIC_GUILDS = 3;
|
||||
const NUMBER_OF_USERS_GUILDS = 2;
|
||||
|
||||
let user, api;
|
||||
let user;
|
||||
|
||||
before(() => {
|
||||
let leader, createdGroup;
|
||||
@@ -26,7 +25,6 @@ describe('GET /groups', () => {
|
||||
});
|
||||
}).then((_user) => {
|
||||
leader = _user;
|
||||
api = requester(leader);
|
||||
|
||||
let publicGuildWithUserAsMember = generateGroup(leader, {
|
||||
name: 'public guild - is member',
|
||||
@@ -70,8 +68,7 @@ describe('GET /groups', () => {
|
||||
|
||||
return Promise.all(promises);
|
||||
}).then((groups) => {
|
||||
api = requester(user);
|
||||
return api.post('/groups', {
|
||||
return user.post('/groups', {
|
||||
type: 'party',
|
||||
name: 'user\'s party',
|
||||
privacy: 'private',
|
||||
@@ -87,7 +84,7 @@ describe('GET /groups', () => {
|
||||
context('tavern passed in as query', () => {
|
||||
|
||||
it('returns only the tavern', () => {
|
||||
return expect(api.get('/groups', null, {type: 'tavern'}))
|
||||
return expect(user.get('/groups', null, {type: 'tavern'}))
|
||||
.to.eventually.have.a.lengthOf(1)
|
||||
.and.to.have.deep.property('[0]')
|
||||
.and.to.have.property('_id', 'habitrpg');
|
||||
@@ -97,7 +94,7 @@ describe('GET /groups', () => {
|
||||
context('party passed in as query', () => {
|
||||
|
||||
it('returns only the user\'s party', () => {
|
||||
return expect(api.get('/groups', null, {type: 'party'}))
|
||||
return expect(user.get('/groups', null, {type: 'party'}))
|
||||
.to.eventually.have.a.lengthOf(1)
|
||||
.and.to.have.deep.property('[0]')
|
||||
.and.to.have.property('leader', user._id);
|
||||
@@ -107,7 +104,7 @@ describe('GET /groups', () => {
|
||||
context('public passed in as query', () => {
|
||||
|
||||
it('returns all public guilds', () => {
|
||||
return expect(api.get('/groups', null, {type: 'public'}))
|
||||
return expect(user.get('/groups', null, {type: 'public'}))
|
||||
.to.eventually.have.a.lengthOf(NUMBER_OF_PUBLIC_GUILDS);
|
||||
});
|
||||
});
|
||||
@@ -115,7 +112,7 @@ describe('GET /groups', () => {
|
||||
context('guilds passed in as query', () => {
|
||||
|
||||
it('returns all guilds user is a part of ', () => {
|
||||
return expect(api.get('/groups', null, {type: 'guilds'}))
|
||||
return expect(user.get('/groups', null, {type: 'guilds'}))
|
||||
.to.eventually.have.a.lengthOf(NUMBER_OF_USERS_GUILDS);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user