move range and delay over to util module
This commit is contained in:
parent
5745e9ed0c
commit
923ae90576
3 changed files with 32 additions and 11 deletions
|
@ -21,6 +21,7 @@ const join = require('./tests/join');
|
|||
const sendMessage = require('./tests/send-message');
|
||||
const acceptInvite = require('./tests/accept-invite');
|
||||
const invite = require('./tests/invite');
|
||||
const {delay, range} = require('./util');
|
||||
const {
|
||||
receiveMessage,
|
||||
checkTimelineContains,
|
||||
|
@ -49,14 +50,6 @@ module.exports = async function scenario(createSession, restCreator) {
|
|||
await aLazyLoadingTest(alice, bob, charlies);
|
||||
}
|
||||
|
||||
function range(start, amount, step = 1) {
|
||||
const r = [];
|
||||
for (let i = 0; i < amount; ++i) {
|
||||
r.push(start + (i * step));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
async function createRestUsers(restCreator) {
|
||||
const usernames = range(1, 10).map((i) => `charly-${i}`);
|
||||
const charlies = await restCreator.createSessionRange(usernames, 'testtest');
|
||||
|
@ -88,12 +81,12 @@ async function createE2ERoomAndTalk(alice, bob) {
|
|||
const bobDevice = await getE2EDeviceFromSettings(bob);
|
||||
// wait some time for the encryption warning dialog
|
||||
// to appear after closing the settings
|
||||
await bob.delay(1000);
|
||||
await delay(1000);
|
||||
await acceptDialogMaybe(bob, "encryption");
|
||||
const aliceDevice = await getE2EDeviceFromSettings(alice);
|
||||
// wait some time for the encryption warning dialog
|
||||
// to appear after closing the settings
|
||||
await alice.delay(1000);
|
||||
await delay(1000);
|
||||
await acceptDialogMaybe(alice, "encryption");
|
||||
await verifyDeviceForUser(bob, "alice", aliceDevice);
|
||||
await verifyDeviceForUser(alice, "bob", bobDevice);
|
||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
const puppeteer = require('puppeteer');
|
||||
const Logger = require('./logger');
|
||||
const LogBuffer = require('./logbuffer');
|
||||
const {delay} = require('./util');
|
||||
|
||||
module.exports = class RiotSession {
|
||||
constructor(browser, page, username, riotserver, hsUrl) {
|
||||
|
@ -169,7 +170,7 @@ module.exports = class RiotSession {
|
|||
}
|
||||
|
||||
delay(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
return delay(ms);
|
||||
}
|
||||
|
||||
close() {
|
||||
|
|
27
src/util.js
Normal file
27
src/util.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
Copyright 2018 New Vector Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
module.exports.range = function(start, amount, step = 1) {
|
||||
const r = [];
|
||||
for (let i = 0; i < amount; ++i) {
|
||||
r.push(start + (i * step));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
module.exports.delay = function(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
Loading…
Reference in a new issue