mirror of
https://github.com/logseq/logseq.git
synced 2026-04-28 16:15:21 +00:00
test(e2e): fs testings - file create, rename, unlink
This commit is contained in:
42
e2e-tests/util/basic.ts
Normal file
42
e2e-tests/util/basic.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user