Tidy makeCommit and test resetCommitState in repo_commit_section

This commit is contained in:
Luke "Jared" Bennett 2017-08-07 13:08:12 +01:00
parent 62e3b28c56
commit d0bcf0170b
No known key found for this signature in database
GPG Key ID: 402ED51FB5D306C2
2 changed files with 32 additions and 8 deletions

View File

@ -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');
},
},
};

View File

@ -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);
});
});
});
});