mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 05:07:22 +01:00
* remove some unused dependencies * update mongoose version * make common tests pass * Make unit tests pass * make api v3 integration tests pass * fix lint issues * fix issue with package-lock * fix(lint): we don't need no .js * fix(lint): update to latest config-habitrpg * chore(npm): update package locks * fix(test): replace deprecated fn * chore(package): update eslint-habitrpg again * fix(lint): server linting * fix(lint): client linting * fix(client): correct mangled common imports * chore(npm): update package-locks * fix(lint): punctuation, module --------- Co-authored-by: SabreCat <sabrecat@gmail.com> Co-authored-by: SabreCat <sabe@habitica.com>
56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
/* eslint-disable global-require */
|
|
import nconf from 'nconf';
|
|
import { generateUser } from '../../../helpers/api-unit.helper';
|
|
import * as emailLib from '../../../../website/server/libs/email';
|
|
import { bugReportLogic } from '../../../../website/server/libs/bug-report';
|
|
|
|
describe('bug-report', () => {
|
|
beforeEach(() => {
|
|
sandbox.stub(emailLib, 'sendTxn').returns(Promise.resolve());
|
|
|
|
const nconfGetStub = sandbox.stub(nconf, 'get');
|
|
nconfGetStub.withArgs('ADMIN_EMAIL').returns('true');
|
|
});
|
|
|
|
afterEach(() => {
|
|
sandbox.restore();
|
|
});
|
|
|
|
it('sends a mail using sendTxn', async () => {
|
|
const userId = '2b58daeb-bc50-4a83-b5d3-4ac52c7c0608';
|
|
const userMail = 'me@me.com';
|
|
const userMessage = 'The power is over 9000, please fix it';
|
|
const userAgent = 'The UserAgent with a bunch of weird browser engine levels';
|
|
|
|
const user = generateUser({
|
|
_id: userId,
|
|
});
|
|
|
|
const result = await bugReportLogic(user, userMail, userMessage, userAgent);
|
|
|
|
expect(emailLib.sendTxn).to.be.called;
|
|
expect(result).to.deep.equal({
|
|
sendMailResult: undefined,
|
|
emailData: {
|
|
BROWSER_UA: userAgent,
|
|
REPORT_MSG: userMessage,
|
|
USER_CLASS: 'warrior',
|
|
USER_CONSECUTIVE_MONTHS: 0,
|
|
USER_COSTUME: 'false',
|
|
USER_CUSTOMER_ID: undefined,
|
|
USER_CUSTOM_DAY: 0,
|
|
USER_DAILIES_PAUSED: 'false',
|
|
USER_EMAIL: userMail,
|
|
USER_HOURGLASSES: 0,
|
|
USER_ID: userId,
|
|
USER_LEVEL: 1,
|
|
USER_OFFSET_MONTHS: 0,
|
|
USER_PAYMENT_PLATFORM: undefined,
|
|
USER_SUBSCRIPTION: undefined,
|
|
USER_TIMEZONE_OFFSET: 0,
|
|
USER_USERNAME: undefined,
|
|
},
|
|
});
|
|
});
|
|
});
|