Update tests to assert against translation strings
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../helpers/api.helper';
|
||||
|
||||
describe('DELETE /user', () => {
|
||||
@@ -17,10 +18,14 @@ describe('DELETE /user', () => {
|
||||
return api.get('/user');
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
text: 'No user found.',
|
||||
text: t('messageAuthNoUserFound'),
|
||||
});
|
||||
});
|
||||
|
||||
context('user has active subscription', () => {
|
||||
it('does not delete account');
|
||||
});
|
||||
|
||||
context('user in solo group', () => {
|
||||
|
||||
it('deletes party when user is the only member');
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../helpers/api.helper';
|
||||
|
||||
describe('GET /user/tags/id', () => {
|
||||
@@ -22,7 +23,7 @@ describe('GET /user/tags/id', () => {
|
||||
return expect(api.get('/user/tags/not-an-id'))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
text: 'Tag not found.'
|
||||
text: t('messageTagNotFound'),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../helpers/api.helper';
|
||||
|
||||
import { each } from 'lodash';
|
||||
@@ -15,7 +16,7 @@ describe('PUT /user', () => {
|
||||
});
|
||||
});
|
||||
|
||||
context('allowed paths', () => {
|
||||
context('allowed operations', () => {
|
||||
it('updates the user', () => {
|
||||
return api.put('/user', {
|
||||
'profile.name' : 'Frodo',
|
||||
@@ -29,8 +30,8 @@ describe('PUT /user', () => {
|
||||
});
|
||||
});
|
||||
|
||||
context('top level protected paths', () => {
|
||||
let protectedPaths = {
|
||||
context('top level protected operations', () => {
|
||||
let protectedOperations = {
|
||||
'gem balance': {balance: 100},
|
||||
'auth': {'auth.blocked': true, 'auth.timestamps.created': new Date()},
|
||||
'contributor': {'contributor.level': 9, 'contributor.admin': true, 'contributor.text': 'some text'},
|
||||
@@ -40,11 +41,11 @@ describe('PUT /user', () => {
|
||||
'tasks': {todos: [], habits: [], dailys: [], rewards: []},
|
||||
};
|
||||
|
||||
each(protectedPaths, (data, testName) => {
|
||||
each(protectedOperations, (data, testName) => {
|
||||
it(`does not allow updating ${testName}`, () => {
|
||||
let errorText = [];
|
||||
each(data, (value, path) => {
|
||||
errorText.push(`path \`${path}\` was not saved, as it's a protected path.`);
|
||||
each(data, (value, operation) => {
|
||||
errorText.push(t('messageUserOperationProtected', { operation: operation }));
|
||||
});
|
||||
return expect(api.put('/user', data)).to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
@@ -54,16 +55,16 @@ describe('PUT /user', () => {
|
||||
});
|
||||
});
|
||||
|
||||
context('sub-level protected paths', () => {
|
||||
let protectedPaths = {
|
||||
context('sub-level protected operations', () => {
|
||||
let protectedOperations = {
|
||||
'class stat': {'stats.class': 'wizard'},
|
||||
};
|
||||
|
||||
each(protectedPaths, (data, testName) => {
|
||||
each(protectedOperations, (data, testName) => {
|
||||
it(`does not allow updating ${testName}`, () => {
|
||||
let errorText = [];
|
||||
each(data, (value, path) => {
|
||||
errorText.push(`path \`${path}\` was not saved, as it's a protected path.`);
|
||||
each(data, (value, operation) => {
|
||||
errorText.push(t('messageUserOperationProtected', { operation: operation }));
|
||||
});
|
||||
return expect(api.put('/user', data)).to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../../helpers/api.helper';
|
||||
|
||||
import { each } from 'lodash';
|
||||
@@ -49,7 +50,7 @@ describe('POST /user/batch-update', () => {
|
||||
{op: operation},
|
||||
])).to.eventually.be.rejected.and.eql({
|
||||
code: 500,
|
||||
text: `${operation} operation not found`,
|
||||
text: t('messageUserOperationNotFound', { operation: operation}),
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -61,7 +62,7 @@ describe('POST /user/batch-update', () => {
|
||||
{op: 'aNotRealOperation'},
|
||||
])).to.eventually.be.rejected.and.eql({
|
||||
code: 500,
|
||||
text: 'aNotRealOperation operation not found',
|
||||
text: t('messageUserOperationNotFound', { operation: 'aNotRealOperation' }),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../../helpers/api.helper';
|
||||
|
||||
describe('DELETE /user/tasks/:id', () => {
|
||||
@@ -20,7 +21,7 @@ describe('DELETE /user/tasks/:id', () => {
|
||||
return api.get(`/user/tasks/${task.id}`);
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
text: 'No task found.',
|
||||
text: t('messageTaskNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,7 +29,7 @@ describe('DELETE /user/tasks/:id', () => {
|
||||
return expect(api.del('/user/tasks/task-that-does-not-exist'))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
text: 'Task not found.',
|
||||
text: t('messageTaskNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../../helpers/api.helper';
|
||||
|
||||
describe('GET /user/tasks/', () => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../../helpers/api.helper';
|
||||
|
||||
describe('GET /user/tasks/:id', () => {
|
||||
@@ -28,7 +29,7 @@ describe('GET /user/tasks/:id', () => {
|
||||
return expect(api.get('/user/tasks/task-that-does-not-exist'))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
text: 'No task found.',
|
||||
text: t('messageTaskNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -38,7 +39,7 @@ describe('GET /user/tasks/:id', () => {
|
||||
return api.get(`/user/tasks/${otherUsersTask.id}`);
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
text: 'No task found.',
|
||||
text: t('messageTaskNotFound'),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../../helpers/api.helper';
|
||||
|
||||
describe('POST /user/tasks', () => {
|
||||
@@ -46,7 +47,7 @@ describe('POST /user/tasks', () => {
|
||||
id: todo.id,
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 409,
|
||||
text: 'A task with that ID already exists.',
|
||||
text: t('messageDuplicateTaskID'),
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../../helpers/api.helper';
|
||||
|
||||
describe('PUT /user/tasks/:id', () => {
|
||||
|
||||
Reference in New Issue
Block a user