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

Commit c85a910

Browse files
committed
✅ remaining tests :fingers_crossed:
1 parent 7aacfa4 commit c85a910

File tree

3 files changed

+22
-37
lines changed

3 files changed

+22
-37
lines changed

test/views/dialog-view.test.js

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -88,38 +88,7 @@ describe('DialogView', function() {
8888
const button = wrapper.find('.btn-primary');
8989
assert.isTrue(button.hasClass('icon'));
9090
assert.isTrue(button.hasClass('icon-repo-clone'));
91-
assert.strictEqual(button.text(), 'Engage');
92-
});
93-
});
94-
95-
describe('tabbing', function() {
96-
let div;
97-
98-
beforeEach(function() {
99-
div = document.createElement('div');
100-
div.tabIndex = 1000000;
101-
document.body.appendChild(div);
102-
});
103-
104-
afterEach(function() {
105-
div.remove();
106-
});
107-
108-
it('assigns successive distinct tab indices to button elements', function() {
109-
const tabGroup = new TabGroup();
110-
const wrapper = shallow(buildApp({tabGroup}));
111-
112-
assert.strictEqual(wrapper.find('.github-Dialog-cancelButton').prop('tabIndex'), 1000001);
113-
assert.strictEqual(wrapper.find('.btn-primary').prop('tabIndex'), 1000002);
114-
});
115-
116-
it('recaptures focus after it leaves the dialog element', function() {
117-
const tabGroup = new TabGroup();
118-
const wrapper = shallow(buildApp({tabGroup}));
119-
120-
sinon.spy(tabGroup, 'focusBeginning');
121-
wrapper.find('.github-Dialog').prop('onTransitionEnd')();
122-
assert.isTrue(tabGroup.focusBeginning.called);
91+
assert.strictEqual(button.prop('children'), 'Engage');
12392
});
12493
});
12594

test/views/directory-select.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {TextBuffer} from 'atom';
44

55
import DirectorySelect from '../../lib/views/directory-select';
66
import TabGroup from '../../lib/tab-group';
7+
import {TabbableTextEditor} from '../../lib/views/tabbable';
78

89
describe('DirectorySelect', function() {
910
let atomEnv;
@@ -34,13 +35,13 @@ describe('DirectorySelect', function() {
3435
const buffer = new TextBuffer();
3536
const wrapper = shallow(buildApp({buffer}));
3637

37-
assert.strictEqual(wrapper.find('AtomTextEditor.github-DirectorySelect-destinationPath').prop('buffer'), buffer);
38+
assert.strictEqual(wrapper.find('.github-DirectorySelect-destinationPath').prop('buffer'), buffer);
3839
});
3940

4041
it('disables both controls', function() {
4142
const wrapper = shallow(buildApp({disabled: true}));
4243

43-
assert.isTrue(wrapper.find('AtomTextEditor').prop('readOnly'));
44+
assert.isTrue(wrapper.find(TabbableTextEditor).prop('readOnly'));
4445
assert.isTrue(wrapper.find('.btn.icon-file-directory').prop('disabled'));
4546
});
4647

test/views/open-commit-dialog.test.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import OpenCommitDialog, {openCommitDetailItem} from '../../lib/views/open-commi
55
import {dialogRequests} from '../../lib/controllers/dialogs-controller';
66
import CommitDetailItem from '../../lib/items/commit-detail-item';
77
import {GitError} from '../../lib/git-shell-out-strategy';
8+
import {TabbableTextEditor} from '../../lib/views/tabbable';
89
import * as reporterProxy from '../../lib/reporter-proxy';
910

1011
describe('OpenCommitDialog', function() {
@@ -19,7 +20,7 @@ describe('OpenCommitDialog', function() {
1920
});
2021

2122
function isValidRef(ref) {
22-
return Promise.resolve(ref === 'abcd1234');
23+
return Promise.resolve(/^abcd/.test(ref));
2324
}
2425

2526
function buildApp(overrides = {}) {
@@ -46,9 +47,12 @@ describe('OpenCommitDialog', function() {
4647

4748
it('enables the open button when commit sha box is populated', function() {
4849
const wrapper = shallow(buildApp());
49-
wrapper.find('AtomTextEditor').prop('buffer').setText('abcd1234');
50+
wrapper.find(TabbableTextEditor).prop('buffer').setText('abcd1234');
5051

5152
assert.isTrue(wrapper.find('DialogView').prop('acceptEnabled'));
53+
54+
wrapper.find(TabbableTextEditor).prop('buffer').setText('abcd6789');
55+
assert.isTrue(wrapper.find('DialogView').prop('acceptEnabled'));
5256
});
5357
});
5458

@@ -58,13 +62,24 @@ describe('OpenCommitDialog', function() {
5862
request.onAccept(accept);
5963

6064
const wrapper = shallow(buildApp({request}));
61-
wrapper.find('AtomTextEditor').prop('buffer').setText('abcd1234');
65+
wrapper.find(TabbableTextEditor).prop('buffer').setText('abcd1234');
6266
wrapper.find('DialogView').prop('accept')();
6367

6468
assert.isTrue(accept.calledWith('abcd1234'));
6569
wrapper.unmount();
6670
});
6771

72+
it('does nothing on accept if the ref is empty', async function() {
73+
const accept = sinon.spy();
74+
const request = dialogRequests.commit();
75+
request.onAccept(accept);
76+
77+
const wrapper = shallow(buildApp({request}));
78+
await wrapper.find('DialogView').prop('accept')();
79+
80+
assert.isFalse(accept.called);
81+
});
82+
6883
it('calls the cancellation callback', function() {
6984
const cancel = sinon.spy();
7085
const request = dialogRequests.commit();

0 commit comments

Comments
 (0)