import {clone, extend} from "@util/JsonToolkit"; const request = require('supertest'); const globalAny: any = global; export const DatetimeRegex = /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d$/; export const DateRegex = /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/; const json: any = { ver: '1.0', app_id: 'test-app-id', timestamp: new Date().getTime(), token: 'token', __cachedData: {}, } export const api = async (path: string, data: any): Promise => { try { let req = clone(json); req.__cachedData.user_id = globalAny.user_id; req = extend(req, {data: data}); let response = await request(globalAny.app) .post(path).send(req); return response.body; } catch (e) { console.error('Could not request', e); } };