mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
tests(api): Reorganize integration helper for v2
This commit is contained in:
@@ -2,7 +2,7 @@ import {
|
||||
generateGroup,
|
||||
generateUser,
|
||||
resetHabiticaDB,
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
} from '../../../helpers/api-integration/v2';
|
||||
|
||||
describe('GET /groups', () => {
|
||||
const NUMBER_OF_PUBLIC_GUILDS = 3;
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
createAndPopulateGroup,
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
} from '../../../helpers/api-integration/v2';
|
||||
import {
|
||||
find,
|
||||
each,
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
generateGroup,
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
} from '../../../helpers/api-integration/v2';
|
||||
|
||||
describe('POST /groups', () => {
|
||||
context('All groups', () => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
generateGroup,
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
} from '../../../helpers/api-integration/v2';
|
||||
|
||||
describe('POST /groups/:id', () => {
|
||||
context('user is not the leader of the group', () => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
createAndPopulateGroup,
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
} from '../../../helpers/api-integration/v2';
|
||||
import { each, find } from 'lodash';
|
||||
|
||||
describe('POST /groups/:id/join', () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
checkExistence,
|
||||
createAndPopulateGroup,
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
} from '../../../helpers/api-integration/v2';
|
||||
import { find } from 'lodash';
|
||||
|
||||
describe('POST /groups/:id/leave', () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
createAndPopulateGroup,
|
||||
translate as t,
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
} from '../../../helpers/api-integration/v2';
|
||||
|
||||
describe('POST /groups/:id/removeMember', () => {
|
||||
context('user is not member of the group', () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
createAndPopulateGroup,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
} from '../../../../helpers/api-integration/v2';
|
||||
|
||||
describe('DELETE /groups/:id/chat', () => {
|
||||
let group, message, user;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
createAndPopulateGroup,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
} from '../../../../helpers/api-integration/v2';
|
||||
|
||||
describe('GET /groups/:id/chat', () => {
|
||||
context('group with multiple messages', () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
createAndPopulateGroup,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
} from '../../../../helpers/api-integration/v2';
|
||||
|
||||
describe('POST /groups/:id/chat', () => {
|
||||
let group, user;
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
createAndPopulateGroup,
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
} from '../../../../helpers/api-integration/v2';
|
||||
|
||||
describe('POST /groups/:id/chat/:id/clearflags', () => {
|
||||
let guild;
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
createAndPopulateGroup,
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
} from '../../../../helpers/api-integration/v2';
|
||||
|
||||
describe('POST /groups/:id/chat/:id/flag', () => {
|
||||
context('another member\'s message', () => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
createAndPopulateGroup,
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
} from '../../../../helpers/api-integration/v2';
|
||||
|
||||
describe('POST /groups/:id/chat/:id/like', () => {
|
||||
context('another member\'s message', () => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
} from '../../../helpers/api-integration/v2';
|
||||
import { v4 as generateRandomUserName } from 'uuid';
|
||||
import { each } from 'lodash';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {requester} from '../../../helpers/api-integration.helper';
|
||||
import {requester} from '../../../helpers/api-integration/v2';
|
||||
|
||||
describe('Status', () => {
|
||||
it('returns a status of up when server is up', async () => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
createAndPopulateGroup,
|
||||
generateGroup,
|
||||
generateUser,
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
} from '../../../helpers/api-integration/v2';
|
||||
import { find } from 'lodash';
|
||||
|
||||
describe('DELETE /user', () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
} from '../../../helpers/api-integration/v2';
|
||||
|
||||
describe('GET /user', () => {
|
||||
let user;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
} from '../../../helpers/api-integration/v2';
|
||||
|
||||
describe('GET /user/tags', () => {
|
||||
let user;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
} from '../../../helpers/api-integration/v2';
|
||||
|
||||
describe('GET /user/tags/id', () => {
|
||||
let user;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../helpers/api-integration.helper';
|
||||
} from '../../../helpers/api-integration/v2';
|
||||
|
||||
import { each, get } from 'lodash';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
} from '../../../../helpers/api-integration/v2';
|
||||
import { each } from 'lodash';
|
||||
|
||||
describe('GET /user/anonymized', () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
} from '../../../../helpers/api-integration/v2';
|
||||
|
||||
import { each } from 'lodash';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
} from '../../../../helpers/api-integration/v2';
|
||||
|
||||
describe('POST /user/pushDevice', () => {
|
||||
let user;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
} from '../../../../helpers/api-integration/v2';
|
||||
|
||||
describe('DELETE /user/tasks/:id', () => {
|
||||
let user, task;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
} from '../../../../helpers/api-integration/v2';
|
||||
|
||||
describe('GET /user/tasks/', () => {
|
||||
let user;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
} from '../../../../helpers/api-integration/v2';
|
||||
|
||||
describe('GET /user/tasks/:id', () => {
|
||||
let user, task;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
} from '../../../../helpers/api-integration/v2';
|
||||
|
||||
describe('POST /user/tasks', () => {
|
||||
let user;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
} from '../../../../helpers/api-integration/v2';
|
||||
|
||||
describe('PUT /user/tasks/:id', () => {
|
||||
let user, task;
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
/* eslint-disable no-use-before-define */
|
||||
|
||||
// Import requester function, set it up for v2, export it
|
||||
import { requester } from './api-integration/requester'
|
||||
requester.setApiVersion('v2');
|
||||
export { requester };
|
||||
|
||||
export { translate } from './api-integration/translate';
|
||||
export { checkExistence, resetHabiticaDB } from './api-integration/mongo';
|
||||
export {
|
||||
generateUser,
|
||||
generateGroup,
|
||||
createAndPopulateGroup,
|
||||
} from './api-integration/v2/object-generators';
|
||||
14
test/helpers/api-integration/v2/index.js
Normal file
14
test/helpers/api-integration/v2/index.js
Normal file
@@ -0,0 +1,14 @@
|
||||
/* eslint-disable no-use-before-define */
|
||||
|
||||
// Import requester function, set it up for v2, export it
|
||||
import { requester } from '../requester'
|
||||
requester.setApiVersion('v2');
|
||||
export { requester };
|
||||
|
||||
export { translate } from '../translate';
|
||||
export { checkExistence, resetHabiticaDB } from '../mongo';
|
||||
export {
|
||||
generateUser,
|
||||
generateGroup,
|
||||
createAndPopulateGroup,
|
||||
} from './object-generators';
|
||||
Reference in New Issue
Block a user