Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/ide/file_helpers.js')
-rw-r--r--spec/frontend/ide/file_helpers.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/frontend/ide/file_helpers.js b/spec/frontend/ide/file_helpers.js
new file mode 100644
index 00000000000..326f8b9716d
--- /dev/null
+++ b/spec/frontend/ide/file_helpers.js
@@ -0,0 +1,35 @@
+export const createFile = (path, content = '') => ({
+ id: path,
+ path,
+ content,
+ raw: content,
+});
+
+export const createNewFile = (path, content) =>
+ Object.assign(createFile(path, content), {
+ tempFile: true,
+ raw: '',
+ });
+
+export const createDeletedFile = (path, content) =>
+ Object.assign(createFile(path, content), {
+ deleted: true,
+ });
+
+export const createUpdatedFile = (path, oldContent, content) =>
+ Object.assign(createFile(path, content), {
+ raw: oldContent,
+ });
+
+export const createMovedFile = (path, prevPath, content) =>
+ Object.assign(createNewFile(path, content), {
+ prevPath,
+ });
+
+export const createEntries = path =>
+ path.split('/').reduce((acc, part, idx, parts) => {
+ const parentPath = parts.slice(0, idx).join('/');
+ const fullPath = parentPath ? `${parentPath}/${part}` : part;
+
+ return Object.assign(acc, { [fullPath]: { ...createFile(fullPath), parentPath } });
+ }, {});