diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/frontend/ide/file_helpers.js | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) | |
download | gitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/frontend/ide/file_helpers.js')
-rw-r--r-- | spec/frontend/ide/file_helpers.js | 35 |
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 } }); + }, {}); |