Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createUsers() {
const promises = [];
const createdUsers = [];
for (let i = 0; i < count; i += 1) {
const userConfig = config ? config[i] : {};
promises.push(testUsers.create({count: 1, config: userConfig}).then((usersArray) => {
createdUsers.push(usersArray[0]);
}));
}
return Promise.all(promises)
.then(() => storeUsers(createdUsers))
// Adding delay for test user creation propagation
.then(() => new Promise((resolve) => {
setTimeout(resolve, 3000);
}));
}
before('create lorraine', () => testUsers.create({count: 1, config: {displayName: 'Lorraine Baines'}})
.then((users) => {
[lorraine] = users;
lorraine.spark = new CiscoSpark({
credentials: {
authorization: lorraine.token,
federation: true
},
config: {
logger: {
level: 'error'
}
}
});
return lorraine.spark.internal.mercury.connect();
}));
before('create marty', () => testUsers.create({count: 1, config: {displayName: 'Marty McFly'}})
.then((users) => {
[marty] = users;
marty.spark = new CiscoSpark({
credentials: {
authorization: marty.token,
federation: true
},
config: {
logger: {
level: 'error'
}
}
});
return marty.spark.internal.mercury.connect();
}));