mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 13:17:24 +01:00
fix unit tests
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable camelcase */
|
||||
import analyticsService from '../../../../website/server/libs/analyticsService';
|
||||
import * as analyticsService from '../../../../website/server/libs/analyticsService';
|
||||
import Amplitude from 'amplitude';
|
||||
import { Visitor } from 'universal-analytics';
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { recoverCron, cron } from '../../../../website/server/libs/cron';
|
||||
import { model as User } from '../../../../website/server/models/user';
|
||||
import * as Tasks from '../../../../website/server/models/task';
|
||||
import common from '../../../../website/common';
|
||||
import analytics from '../../../../website/server/libs/analyticsService';
|
||||
import * as analytics from '../../../../website/server/libs/analyticsService';
|
||||
|
||||
// const scoreTask = common.ops.scoreTask;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import moment from 'moment';
|
||||
|
||||
import * as sender from '../../../../../../website/server/libs/email';
|
||||
import * as api from '../../../../../../website/server/libs/payments/payments';
|
||||
import api from '../../../../../../website/server/libs/payments/payments';
|
||||
import { model as User } from '../../../../../../website/server/models/user';
|
||||
import { model as Group } from '../../../../../../website/server/models/group';
|
||||
import {
|
||||
|
||||
@@ -3,7 +3,7 @@ import stripeModule from 'stripe';
|
||||
import nconf from 'nconf';
|
||||
|
||||
import * as sender from '../../../../../../website/server/libs/email';
|
||||
import * as api from '../../../../../../website/server/libs/payments/payments';
|
||||
import api from '../../../../../../website/server/libs/payments/payments';
|
||||
import amzLib from '../../../../../../website/server/libs/payments/amazon';
|
||||
import paypalPayments from '../../../../../../website/server/libs/payments/paypal';
|
||||
import stripePayments from '../../../../../../website/server/libs/payments/stripe';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import moment from 'moment';
|
||||
|
||||
import * as sender from '../../../../../website/server/libs/email';
|
||||
import * as api from '../../../../../website/server/libs/payments/payments';
|
||||
import analytics from '../../../../../website/server/libs/analyticsService';
|
||||
import notifications from '../../../../../website/server/libs/pushNotifications';
|
||||
import api from '../../../../../website/server/libs/payments/payments';
|
||||
import * as analytics from '../../../../../website/server/libs/analyticsService';
|
||||
import * as notifications from '../../../../../website/server/libs/pushNotifications';
|
||||
import { model as User } from '../../../../../website/server/models/user';
|
||||
import { translate as t } from '../../../../helpers/api-integration/v3';
|
||||
import {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable camelcase */
|
||||
import { IncomingWebhook } from '@slack/client';
|
||||
import requireAgain from 'require-again';
|
||||
import slack from '../../../../website/server/libs/slack';
|
||||
import * as slack from '../../../../website/server/libs/slack';
|
||||
import logger from '../../../../website/server/libs/logger';
|
||||
import { TAVERN_ID } from '../../../../website/server/models/group';
|
||||
import nconf from 'nconf';
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
generateReq,
|
||||
generateNext,
|
||||
} from '../../../helpers/api-unit.helper';
|
||||
import analyticsService from '../../../../website/server/libs/analyticsService';
|
||||
import * as analyticsService from '../../../../website/server/libs/analyticsService';
|
||||
import nconf from 'nconf';
|
||||
import requireAgain from 'require-again';
|
||||
|
||||
@@ -19,7 +19,7 @@ describe('analytics middleware', () => {
|
||||
});
|
||||
|
||||
it('attaches analytics object res.locals', () => {
|
||||
let attachAnalytics = requireAgain(pathToAnalyticsMiddleware);
|
||||
let attachAnalytics = requireAgain(pathToAnalyticsMiddleware).default;
|
||||
|
||||
attachAnalytics(req, res, next);
|
||||
|
||||
@@ -28,7 +28,7 @@ describe('analytics middleware', () => {
|
||||
|
||||
it('attaches stubbed methods for non-prod environments', () => {
|
||||
sandbox.stub(nconf, 'get').withArgs('IS_PROD').returns(false);
|
||||
let attachAnalytics = requireAgain(pathToAnalyticsMiddleware);
|
||||
let attachAnalytics = requireAgain(pathToAnalyticsMiddleware).default;
|
||||
|
||||
attachAnalytics(req, res, next);
|
||||
|
||||
@@ -39,7 +39,7 @@ describe('analytics middleware', () => {
|
||||
it('attaches real methods for prod environments', () => {
|
||||
sandbox.stub(nconf, 'get').withArgs('IS_PROD').returns(true);
|
||||
|
||||
let attachAnalytics = requireAgain(pathToAnalyticsMiddleware);
|
||||
let attachAnalytics = requireAgain(pathToAnalyticsMiddleware).default;
|
||||
|
||||
attachAnalytics(req, res, next);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import moment from 'moment';
|
||||
import { model as User } from '../../../../website/server/models/user';
|
||||
import { model as Group } from '../../../../website/server/models/group';
|
||||
import * as Tasks from '../../../../website/server/models/task';
|
||||
import analyticsService from '../../../../website/server/libs/analyticsService';
|
||||
import * as analyticsService from '../../../../website/server/libs/analyticsService';
|
||||
import * as cronLib from '../../../../website/server/libs/cron';
|
||||
import { v4 as generateUUID } from 'uuid';
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ describe('maintenance mode middleware', () => {
|
||||
it('does not return 503 error when maintenance mode is off', () => {
|
||||
req = generateReq();
|
||||
sandbox.stub(nconf, 'get').withArgs('MAINTENANCE_MODE').returns('false');
|
||||
let attachMaintenanceMode = requireAgain(pathToMaintenanceModeMiddleware);
|
||||
let attachMaintenanceMode = requireAgain(pathToMaintenanceModeMiddleware).default;
|
||||
|
||||
attachMaintenanceMode(req, res, next);
|
||||
|
||||
@@ -29,7 +29,7 @@ describe('maintenance mode middleware', () => {
|
||||
it('returns 503 error when maintenance mode is on', () => {
|
||||
req = generateReq();
|
||||
sandbox.stub(nconf, 'get').withArgs('MAINTENANCE_MODE').returns('true');
|
||||
let attachMaintenanceMode = requireAgain(pathToMaintenanceModeMiddleware);
|
||||
let attachMaintenanceMode = requireAgain(pathToMaintenanceModeMiddleware).default;
|
||||
|
||||
attachMaintenanceMode(req, res, next);
|
||||
|
||||
@@ -41,7 +41,7 @@ describe('maintenance mode middleware', () => {
|
||||
it('renders maintenance page when request type is HTML', () => {
|
||||
req = generateReq({headers: {accept: 'text/html'}});
|
||||
sandbox.stub(nconf, 'get').withArgs('MAINTENANCE_MODE').returns('true');
|
||||
let attachMaintenanceMode = requireAgain(pathToMaintenanceModeMiddleware);
|
||||
let attachMaintenanceMode = requireAgain(pathToMaintenanceModeMiddleware).default;
|
||||
|
||||
attachMaintenanceMode(req, res, next);
|
||||
expect(res.render).to.have.been.calledOnce;
|
||||
@@ -50,7 +50,7 @@ describe('maintenance mode middleware', () => {
|
||||
it('sends error message when request type is JSON', () => {
|
||||
req = generateReq({headers: {accept: 'application/json'}});
|
||||
sandbox.stub(nconf, 'get').withArgs('MAINTENANCE_MODE').returns('true');
|
||||
let attachMaintenanceMode = requireAgain(pathToMaintenanceModeMiddleware);
|
||||
let attachMaintenanceMode = requireAgain(pathToMaintenanceModeMiddleware).default;
|
||||
|
||||
attachMaintenanceMode(req, res, next);
|
||||
expect(res.send).to.have.been.calledOnce;
|
||||
|
||||
@@ -10,13 +10,13 @@ import {
|
||||
model as Group,
|
||||
} from '../../../../website/server/models/group';
|
||||
import { model as User } from '../../../../website/server/models/user';
|
||||
import { quests as questScrolls } from '../../../../website/common/script/content';
|
||||
import { quests as questScrolls } from '../../../../website/common/script/content/quests';
|
||||
import {
|
||||
groupChatReceivedWebhook,
|
||||
questActivityWebhook,
|
||||
} from '../../../../website/server/libs/webhook';
|
||||
import * as email from '../../../../website/server/libs/email';
|
||||
import { TAVERN_ID } from '../../../../website/common/script/';
|
||||
import { TAVERN_ID } from '../../../../website/common/script/constants';
|
||||
import shared from '../../../../website/common';
|
||||
|
||||
describe('Group Model', () => {
|
||||
|
||||
@@ -3,6 +3,7 @@ const webpack = require('webpack');
|
||||
const nconf = require('nconf');
|
||||
const setupNconf = require('../../website/server/libs/setupNconf');
|
||||
const { DuplicatesPlugin } = require("inspectpack/plugin");
|
||||
const pkg = require('../../package.json');
|
||||
|
||||
let configFile = path.join(path.resolve(__dirname, '../../config.json'));
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from '../../libs/errors';
|
||||
import { removeFromArray } from '../../libs/collectionManipulators';
|
||||
import { getUserInfo, getGroupUrl, sendTxn } from '../../libs/email';
|
||||
import slack from '../../libs/slack';
|
||||
import * as slack from '../../libs/slack';
|
||||
import { chatReporterFactory } from '../../libs/chatReporting/chatReporterFactory';
|
||||
import { getAuthorEmailFromMessage} from '../../libs/chat';
|
||||
import nconf from 'nconf';
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { authWithHeaders } from '../../middlewares/auth';
|
||||
import ensureDevelpmentMode from '../../middlewares/ensureDevelpmentMode';
|
||||
import { BadRequest } from '../../libs/errors';
|
||||
import { content } from '../../../common';
|
||||
import common from '../../../common';
|
||||
import _ from 'lodash';
|
||||
|
||||
const content = common.content;
|
||||
|
||||
/**
|
||||
* @apiDefine Development Development
|
||||
* These routes only exist while Habitica is in development mode. (Such as running a local instance on your computer)
|
||||
|
||||
@@ -19,9 +19,11 @@ import {
|
||||
sendTxn as sendTxnEmail,
|
||||
} from '../../libs/email';
|
||||
import { sendNotification as sendPushNotification } from '../../libs/pushNotifications';
|
||||
import { achievements } from '../../../../website/common/';
|
||||
import common from '../../../../website/common/';
|
||||
import {sentMessage} from '../../libs/inbox';
|
||||
|
||||
const achievements = common.achievements;
|
||||
|
||||
let api = {};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import { authWithHeaders } from '../../middlewares/auth';
|
||||
import analytics from '../../libs/analyticsService';
|
||||
import * as analytics from '../../libs/analyticsService';
|
||||
import {
|
||||
model as Group,
|
||||
basicFields as basicGroupFields,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { authWithHeaders } from '../../middlewares/auth';
|
||||
import { shops } from '../../../common/';
|
||||
import common from '../../../common/';
|
||||
|
||||
const shops = common.shops;
|
||||
|
||||
let api = {};
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
omit,
|
||||
toArray,
|
||||
} from 'lodash';
|
||||
import { content as Content } from '../../common';
|
||||
import common from '../../common';
|
||||
import logger from './logger';
|
||||
|
||||
const AMPLITUDE_TOKEN = nconf.get('AMPLITUDE_KEY');
|
||||
@@ -28,6 +28,8 @@ if (AMPLITUDE_TOKEN) amplitude = new Amplitude(AMPLITUDE_TOKEN);
|
||||
|
||||
let ga = googleAnalytics(GA_TOKEN);
|
||||
|
||||
const Content = common.content;
|
||||
|
||||
function _lookUpItemName (itemKey) {
|
||||
if (!itemKey) return;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
NotFound,
|
||||
} from '../errors';
|
||||
import { sendTxn } from '../email';
|
||||
import slack from '../slack';
|
||||
import * as slack from '../slack';
|
||||
import { model as Group } from '../../models/group';
|
||||
import { chatModel as Chat } from '../../models/message';
|
||||
import apiError from '../apiError';
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
BadRequest,
|
||||
} from '../errors';
|
||||
import { getUserInfo, sendTxn} from '../email';
|
||||
import slack from '../slack';
|
||||
import * as slack from '../slack';
|
||||
import apiError from '../apiError';
|
||||
|
||||
import * as inboxLib from '../inbox';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import analytics from '../analyticsService';
|
||||
import * as analytics from '../analyticsService';
|
||||
import {
|
||||
getUserInfo,
|
||||
sendTxn as txnEmail,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import _ from 'lodash';
|
||||
import moment from 'moment';
|
||||
|
||||
import analytics from '../analyticsService';
|
||||
import slack from '../slack';
|
||||
import * as analytics from '../analyticsService';
|
||||
import * as slack from '../slack';
|
||||
import {
|
||||
getUserInfo,
|
||||
sendTxn as txnEmail,
|
||||
|
||||
Reference in New Issue
Block a user