UNPKG

qe-fe-automation

Version:
39 lines (34 loc) 996 B
import crypto = require('crypto'); import moment = require('moment'); const MAX_TIMEOUT = { timeout: 30000 }; const MEDIUM_TIMEOUT = { timeout: 10000 }; const SHORT_TIMEOUT = { timeout: 3000 }; const cache: { [key: string]: any } = { id: {} }; export function getShortTimeout() { return SHORT_TIMEOUT.timeout; } export function getMediumTimeout() { return MEDIUM_TIMEOUT.timeout; } export function getMaxTimeout() { return MAX_TIMEOUT.timeout; } export class Dates { static getFutureDate(numberOfDatesToAdd: number, dateFormat = 'YYYY-MM-DD'): string { return moment(moment()).add(numberOfDatesToAdd, 'days').format(dateFormat); } } export class Random { static randomString(length = 6): string { return crypto.randomBytes(length).toString('hex').slice(0, length); } } export class Cache { static putDataInCache(key: string, data: any): any { cache[key] = data; return cache[key]; } static getDataFromCache(key: string): any { return cache[key]; } }