Tidy makeCommit and test resetCommitState in repo_commit_section
This commit is contained in:
parent
62e3b28c56
commit
d0bcf0170b
|
|
@ -41,14 +41,16 @@ const RepoCommitSection = {
|
|||
actions,
|
||||
};
|
||||
Store.submitCommitsLoading = true;
|
||||
Service.commitFiles(payload, () => {
|
||||
Store.submitCommitsLoading = false;
|
||||
this.changedFiles = [];
|
||||
this.openedFiles = [];
|
||||
this.commitMessage = '';
|
||||
this.editMode = false;
|
||||
$('html, body').animate({ scrollTop: 0 }, 'fast');
|
||||
});
|
||||
Service.commitFiles(payload, this.resetCommitState);
|
||||
},
|
||||
|
||||
resetCommitState() {
|
||||
this.submitCommitsLoading = false;
|
||||
this.changedFiles = [];
|
||||
this.openedFiles = [];
|
||||
this.commitMessage = '';
|
||||
this.editMode = false;
|
||||
$('html, body').animate({ scrollTop: 0 }, 'fast');
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -133,4 +133,26 @@ describe('RepoCommitSection', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
fdescribe('methods', () => {
|
||||
describe('resetCommitState', () => {
|
||||
it('should reset store vars and scroll to top', () => {
|
||||
const vm = {
|
||||
submitCommitsLoading: true,
|
||||
changedFiles: new Array(10),
|
||||
openedFiles: new Array(10),
|
||||
commitMessage: 'commitMessage',
|
||||
editMode: true,
|
||||
};
|
||||
|
||||
repoCommitSection.methods.resetCommitState.call(vm);
|
||||
|
||||
expect(vm.submitCommitsLoading).toEqual(false);
|
||||
expect(vm.changedFiles).toEqual([]);
|
||||
expect(vm.openedFiles).toEqual([]);
|
||||
expect(vm.commitMessage).toEqual('');
|
||||
expect(vm.editMode).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue