diff options
Diffstat (limited to 'spec/javascripts/ide/stores/utils_spec.js')
-rw-r--r-- | spec/javascripts/ide/stores/utils_spec.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/javascripts/ide/stores/utils_spec.js b/spec/javascripts/ide/stores/utils_spec.js index e3bf6d40245..0fc9519a6bf 100644 --- a/spec/javascripts/ide/stores/utils_spec.js +++ b/spec/javascripts/ide/stores/utils_spec.js @@ -92,6 +92,16 @@ describe('Multi-file store utils', () => { path: 'deletedFile', deleted: true, }, + { + ...file('renamedFile'), + path: 'renamedFile', + prevPath: 'prevPath', + }, + { + ...file('replacingFile'), + path: 'replacingFile', + replaces: true, + }, ], currentBranchId: 'master', }; @@ -131,6 +141,22 @@ describe('Multi-file store utils', () => { last_commit_id: undefined, previous_path: undefined, }, + { + action: commitActionTypes.move, + file_path: 'renamedFile', + content: null, + encoding: 'text', + last_commit_id: undefined, + previous_path: 'prevPath', + }, + { + action: commitActionTypes.update, + file_path: 'replacingFile', + content: undefined, + encoding: 'text', + last_commit_id: undefined, + previous_path: undefined, + }, ], start_sha: undefined, }); @@ -235,6 +261,41 @@ describe('Multi-file store utils', () => { }, ]); }); + + it('filters out folders from the list', () => { + const files = [ + { + path: 'a', + type: 'blob', + deleted: true, + }, + { + path: 'c', + type: 'tree', + deleted: true, + }, + { + path: 'c/d', + type: 'blob', + deleted: true, + }, + ]; + + const flattendFiles = utils.getCommitFiles(files); + + expect(flattendFiles).toEqual([ + { + path: 'a', + type: 'blob', + deleted: true, + }, + { + path: 'c/d', + type: 'blob', + deleted: true, + }, + ]); + }); }); describe('mergeTrees', () => { |