replace usage of _.extend with Object.assign

This commit is contained in:
Girish Ramakrishnan
2023-05-25 11:27:23 +02:00
parent 79dd50910c
commit e6ba2a6e7a
15 changed files with 62 additions and 71 deletions

View File

@@ -10,8 +10,7 @@ const apptask = require('../apptask.js'),
expect = require('expect.js'),
fs = require('fs'),
paths = require('../paths.js'),
safe = require('safetydance'),
_ = require('underscore');
safe = require('safetydance');
describe('apptask', function () {
const { setup, cleanup, app } = common;
@@ -37,7 +36,7 @@ describe('apptask', function () {
});
it('barfs on empty manifest', async function () {
const badApp = _.extend({ }, app);
const badApp = Object.assign({ }, app);
badApp.manifest = { };
const [error] = await safe(apptask._verifyManifest(badApp.manifest));
@@ -45,8 +44,8 @@ describe('apptask', function () {
});
it('fails on bad manifest', async function () {
const badApp = _.extend({ }, app);
badApp.manifest = _.extend({ }, app.manifest);
const badApp = Object.assign({ }, app);
badApp.manifest = Object.assign({ }, app.manifest);
delete badApp.manifest.httpPort;
const [error] = await safe(apptask._verifyManifest(badApp.manifest));
@@ -54,8 +53,8 @@ describe('apptask', function () {
});
it('barfs on incompatible manifest', async function () {
const badApp = _.extend({ }, app);
badApp.manifest = _.extend({ }, app.manifest);
const badApp = Object.assign({ }, app);
badApp.manifest = Object.assign({ }, app.manifest);
badApp.manifest.maxBoxVersion = '0.0.0'; // max box version is too small
const [error] = await safe(apptask._verifyManifest(badApp.manifest));
@@ -63,7 +62,7 @@ describe('apptask', function () {
});
it('verifies manifest', async function () {
const goodApp = _.extend({ }, app);
const goodApp = Object.assign({ }, app);
await apptask._verifyManifest(goodApp.manifest);
});

View File

@@ -16,8 +16,7 @@ const async = require('async'),
server = require('../server.js'),
settings = require('../settings.js'),
superagent = require('superagent'),
users = require('../users.js'),
_ = require('underscore');
users = require('../users.js');
let gLdapServer;
@@ -193,7 +192,7 @@ describe('External LDAP', function () {
describe('settings', function () {
it('enabling fails with missing url', async function () {
let conf = _.extend({}, LDAP_CONFIG);
let conf = Object.assign({}, LDAP_CONFIG);
delete conf.url;
const [error] = await safe(settings.setExternalLdapConfig(conf));
@@ -201,7 +200,7 @@ describe('External LDAP', function () {
});
it('enabling fails with empty url', async function () {
let conf = _.extend({}, LDAP_CONFIG);
let conf = Object.assign({}, LDAP_CONFIG);
conf.url = '';
const [error] = await safe(settings.setExternalLdapConfig(conf));
@@ -209,7 +208,7 @@ describe('External LDAP', function () {
});
it('enabling fails with missing baseDn', async function () {
let conf = _.extend({}, LDAP_CONFIG);
let conf = Object.assign({}, LDAP_CONFIG);
delete conf.baseDn;
const [error] = await safe(settings.setExternalLdapConfig(conf));
@@ -217,7 +216,7 @@ describe('External LDAP', function () {
});
it('enabling fails with empty baseDn', async function () {
let conf = _.extend({}, LDAP_CONFIG);
let conf = Object.assign({}, LDAP_CONFIG);
conf.baseDn = '';
const [error] = await safe(settings.setExternalLdapConfig(conf));
@@ -225,7 +224,7 @@ describe('External LDAP', function () {
});
it('enabling fails with missing filter', async function () {
let conf = _.extend({}, LDAP_CONFIG);
let conf = Object.assign({}, LDAP_CONFIG);
delete conf.filter;
const [error] = await safe(settings.setExternalLdapConfig(conf));
@@ -233,7 +232,7 @@ describe('External LDAP', function () {
});
it('enabling fails with empty filter', async function () {
let conf = _.extend({}, LDAP_CONFIG);
let conf = Object.assign({}, LDAP_CONFIG);
conf.filter = '';
const [error] = await safe(settings.setExternalLdapConfig(conf));
@@ -250,7 +249,7 @@ describe('External LDAP', function () {
// now test with groups
it('enabling with groups fails with missing groupBaseDn', async function () {
let conf = _.extend({}, LDAP_CONFIG);
let conf = Object.assign({}, LDAP_CONFIG);
conf.syncGroups = true;
delete conf.groupBaseDn;
@@ -259,7 +258,7 @@ describe('External LDAP', function () {
});
it('enabling with groups fails with empty groupBaseDn', async function () {
let conf = _.extend({}, LDAP_CONFIG);
let conf = Object.assign({}, LDAP_CONFIG);
conf.syncGroups = true;
conf.groupBaseDn = '';
@@ -268,7 +267,7 @@ describe('External LDAP', function () {
});
it('enabling with groups fails with missing groupFilter', async function () {
let conf = _.extend({}, LDAP_CONFIG);
let conf = Object.assign({}, LDAP_CONFIG);
conf.syncGroups = true;
delete conf.groupFilter;
@@ -277,7 +276,7 @@ describe('External LDAP', function () {
});
it('enabling with groups fails with empty groupFilter', async function () {
let conf = _.extend({}, LDAP_CONFIG);
let conf = Object.assign({}, LDAP_CONFIG);
conf.syncGroups = true;
conf.groupFilter = '';
@@ -286,7 +285,7 @@ describe('External LDAP', function () {
});
it('enabling with groups fails with missing groupnameField', async function () {
let conf = _.extend({}, LDAP_CONFIG);
let conf = Object.assign({}, LDAP_CONFIG);
conf.syncGroups = true;
delete conf.groupnameField;
@@ -295,7 +294,7 @@ describe('External LDAP', function () {
});
it('enabling with groups fails with empty groupnameField', async function () {
let conf = _.extend({}, LDAP_CONFIG);
let conf = Object.assign({}, LDAP_CONFIG);
conf.syncGroups = true;
conf.groupnameField = '';
@@ -304,7 +303,7 @@ describe('External LDAP', function () {
});
it('enabling with groups succeeds', async function () {
let conf = _.extend({}, LDAP_CONFIG);
let conf = Object.assign({}, LDAP_CONFIG);
conf.syncGroups = true;
await settings.setExternalLdapConfig(conf);
@@ -375,7 +374,7 @@ describe('External LDAP', function () {
});
it('enable with groupSync', async function () {
let conf = _.extend({}, LDAP_CONFIG);
let conf = Object.assign({}, LDAP_CONFIG);
conf.syncGroups = true;
await settings.setExternalLdapConfig(conf);
});
@@ -498,7 +497,7 @@ describe('External LDAP', function () {
});
it('enable auto create', async function () {
let conf = _.extend({}, LDAP_CONFIG);
let conf = Object.assign({}, LDAP_CONFIG);
conf.autoCreate = true;
await settings.setExternalLdapConfig(conf);
});