Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Cover that last branch in OpenCommitDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
smashwilson committed Dec 5, 2018
1 parent bc8405d commit c1debd0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/views/open-commit-dialog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ describe('OpenCommitDialog', function() {
let app, wrapper, didAccept, didCancel;
let repository, workdirPath;


beforeEach(async function() {
atomEnv = global.buildAtomEnvironment();
commandRegistry = atomEnv.commands;
Expand Down Expand Up @@ -71,9 +70,8 @@ describe('OpenCommitDialog', function() {
assert.strictEqual(wrapper.find('.error').text(), 'Not a valid git commit identifier');
});

it('disables open button when commit does not exist in repo', async function() {
it('disables the open button when the commit does not exist in repo', async function() {
setTextIn('.github-CommitSha atom-text-editor', 'abcd1234');
wrapper.update();
wrapper.find('button.icon-commit').simulate('click');

await assert.async.strictEqual(wrapper.update().find('.error').text(), 'Commit with that sha does not exist in this repository');
Expand All @@ -99,6 +97,16 @@ describe('OpenCommitDialog', function() {
wrapper.unmount();
});

it('re-throws other exceptions encountered during acceptance', async function() {
sinon.stub(repository, 'getCommit').throws(new Error('Oh shit'));
const acceptSpy = sinon.spy(wrapper.instance(), 'accept');

setTextIn('.github-CommitSha atom-text-editor', 'abcd1234');
wrapper.find('button.icon-commit').simulate('click');

await assert.isRejected(acceptSpy.lastCall.returnValue, 'Oh shit');
});

it('calls the cancellation callback', function() {
wrapper.find('button.github-CancelButton').simulate('click');
assert.isTrue(didCancel.called);
Expand Down

0 comments on commit c1debd0

Please sign in to comment.