Upgrade server deps (#10017)

* remove unused apn lib and upgrade moment-recur

* upgrade validator

* upgrade got

* request -> got

* fix validation

* fix tests

* upgrade nodemailer

* fix unit tests

* fix webhook tests, upgrade express-validator (using legacy api)

* upgrade js2xmlparser

* update misc packages

* fix linting

* update packages
This commit is contained in:
Matteo Pagliazzi
2018-02-23 15:21:00 +01:00
committed by GitHub
parent cea47e5280
commit 3a1e56cc8e
18 changed files with 646 additions and 397 deletions

View File

@@ -1,27 +1,11 @@
/* eslint-disable global-require */
import request from 'request';
import got from 'got';
import nconf from 'nconf';
import nodemailer from 'nodemailer';
import Bluebird from 'bluebird';
import requireAgain from 'require-again';
import logger from '../../../../../website/server/libs/logger';
import { TAVERN_ID } from '../../../../../website/server/models/group';
function defer () {
let resolve;
let reject;
let promise = new Bluebird((resolveParam, rejectParam) => {
resolve = resolveParam;
reject = rejectParam;
});
return {
resolve,
reject,
promise,
};
}
import { defer } from '../../../../helpers/api-unit.helper';
function getUser () {
return {
@@ -158,7 +142,7 @@ describe('emails', () => {
describe('sendTxnEmail', () => {
beforeEach(() => {
sandbox.stub(request, 'post');
sandbox.stub(got, 'post').returns(defer().promise);
});
afterEach(() => {
@@ -176,8 +160,9 @@ describe('emails', () => {
};
sendTxnEmail(mailingInfo, emailType);
expect(request.post).to.be.calledWith(sinon.match({
json: {
expect(got.post).to.be.calledWith('undefined/job', sinon.match({
json: true,
body: {
data: {
emailType: sinon.match.same(emailType),
to: sinon.match((value) => {
@@ -199,7 +184,7 @@ describe('emails', () => {
};
sendTxnEmail(mailingInfo, emailType);
expect(request.post).not.to.be.called;
expect(got.post).not.to.be.called;
});
it('uses getUserInfo in case of user data', () => {
@@ -210,8 +195,9 @@ describe('emails', () => {
let mailingInfo = getUser();
sendTxnEmail(mailingInfo, emailType);
expect(request.post).to.be.calledWith(sinon.match({
json: {
expect(got.post).to.be.calledWith('undefined/job', sinon.match({
json: true,
body: {
data: {
emailType: sinon.match.same(emailType),
to: sinon.match(val => val[0]._id === mailingInfo._id),
@@ -232,8 +218,9 @@ describe('emails', () => {
let variables = [1, 2, 3];
sendTxnEmail(mailingInfo, emailType, variables);
expect(request.post).to.be.calledWith(sinon.match({
json: {
expect(got.post).to.be.calledWith('undefined/job', sinon.match({
json: true,
body: {
data: {
variables: sinon.match((value) => {
return value[0].name === 'BASE_URL';