Move /e2e -> /e2e-tests
Этот коммит содержится в:
27
e2e-tests/cypress/tests/utils/file.js
Обычный файл
27
e2e-tests/cypress/tests/utils/file.js
Обычный файл
@@ -0,0 +1,27 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
// Converts a file size in bytes into a human-readable string of the form '123MB'.
|
||||
export function fileSizeToString(bytes) {
|
||||
// it's unlikely that we'll have files bigger than this
|
||||
if (bytes > 1024 ** 4) {
|
||||
// check if file is smaller than 10 to display fractions
|
||||
if (bytes < (1024 ** 4) * 10) {
|
||||
return (Math.round((bytes / (1024 ** 4)) * 10) / 10) + 'TB';
|
||||
}
|
||||
return Math.round(bytes / (1024 ** 4)) + 'TB';
|
||||
} else if (bytes > 1024 ** 3) {
|
||||
if (bytes < (1024 ** 3) * 10) {
|
||||
return (Math.round((bytes / (1024 ** 3)) * 10) / 10) + 'GB';
|
||||
}
|
||||
return Math.round(bytes / (1024 ** 3)) + 'GB';
|
||||
} else if (bytes > 1024 ** 2) {
|
||||
if (bytes < (1024 ** 2) * 10) {
|
||||
return (Math.round((bytes / (1024 ** 2)) * 10) / 10) + 'MB';
|
||||
}
|
||||
return Math.round(bytes / (1024 ** 2)) + 'MB';
|
||||
} else if (bytes > 1024) {
|
||||
return Math.round(bytes / 1024) + 'KB';
|
||||
}
|
||||
return bytes + 'B';
|
||||
}
|
||||
Ссылка в новой задаче
Block a user