diff options
Diffstat (limited to 'spec/javascripts/ide/stores/mutations/file_spec.js')
-rw-r--r-- | spec/javascripts/ide/stores/mutations/file_spec.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/javascripts/ide/stores/mutations/file_spec.js b/spec/javascripts/ide/stores/mutations/file_spec.js index 7714f66c9a4..1b41c3c2548 100644 --- a/spec/javascripts/ide/stores/mutations/file_spec.js +++ b/spec/javascripts/ide/stores/mutations/file_spec.js @@ -103,6 +103,43 @@ describe('IDE store file mutations', () => { expect(localState.openFiles[0].rawPath).toEqual(rawPath); expect(localFile.rawPath).toEqual(rawPath); }); + + it('does not mutate certain props on the file', () => { + const path = 'New Path'; + const name = 'New Name'; + localFile.path = path; + localFile.name = name; + + localState.stagedFiles = [localFile]; + localState.changedFiles = [localFile]; + localState.openFiles = [localFile]; + + mutations.SET_FILE_DATA(localState, { + data: { + path: 'Old Path', + name: 'Old Name', + raw: 'Old Raw', + base_raw: 'Old Base Raw', + }, + file: localFile, + }); + + [ + localState.stagedFiles[0], + localState.changedFiles[0], + localState.openFiles[0], + localFile, + ].forEach(f => { + expect(f).toEqual( + jasmine.objectContaining({ + path, + name, + raw: null, + baseRaw: null, + }), + ); + }); + }); }); describe('SET_FILE_RAW_DATA', () => { |