test(e2e): fs testings - file create, rename, unlink

This commit is contained in:
Junyi Du
2023-03-16 21:03:38 +08:00
parent eee7d06c82
commit 3bd3991d9a
5 changed files with 237 additions and 114 deletions

42
e2e-tests/util/basic.ts Normal file
View File

@@ -0,0 +1,42 @@
// This file is used to store basic functions that are used in other utils
// Should have no dependency on other utils
import * as process from 'process'
export const IsMac = process.platform === 'darwin'
export const IsLinux = process.platform === 'linux'
export const IsWindows = process.platform === 'win32'
export const IsCI = process.env.CI === 'true'
export const modKey = IsMac ? 'Meta' : 'Control'
export function randomString(length: number) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
const charactersLength = characters.length;
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
export function randomLowerString(length: number) {
const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
const charactersLength = characters.length;
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
export function randomInt(min: number, max: number): number {
return Math.floor(Math.random() * (max - min + 1) + min)
}
export function randomBoolean(): boolean {
return Math.random() < 0.5;
}