Commit d0bcf017 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Tidy makeCommit and test resetCommitState in repo_commit_section

parent 62e3b28c
...@@ -41,14 +41,16 @@ const RepoCommitSection = { ...@@ -41,14 +41,16 @@ const RepoCommitSection = {
actions, actions,
}; };
Store.submitCommitsLoading = true; Store.submitCommitsLoading = true;
Service.commitFiles(payload, () => { Service.commitFiles(payload, this.resetCommitState);
Store.submitCommitsLoading = false; },
resetCommitState() {
this.submitCommitsLoading = false;
this.changedFiles = []; this.changedFiles = [];
this.openedFiles = []; this.openedFiles = [];
this.commitMessage = ''; this.commitMessage = '';
this.editMode = false; this.editMode = false;
$('html, body').animate({ scrollTop: 0 }, 'fast'); $('html, body').animate({ scrollTop: 0 }, 'fast');
});
}, },
}, },
}; };
......
...@@ -133,4 +133,26 @@ describe('RepoCommitSection', () => { ...@@ -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);
});
});
});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment