Skip to content

Commit 53530f5

Browse files
committed
Add initial commit box tests
1 parent 0278d45 commit 53530f5

File tree

1 file changed

+28
-38
lines changed

1 file changed

+28
-38
lines changed
Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,47 @@
1+
import * as React from 'react';
12
import 'jest';
3+
import { shallow } from 'enzyme';
24
import { CommitBox } from '../../src/components/CommitBox';
3-
import { classes } from 'typestyle';
4-
import {
5-
stagedCommitButtonStyle,
6-
stagedCommitButtonReadyStyle,
7-
stagedCommitButtonDisabledStyle
8-
} from '../../src/style/BranchHeaderStyle';
95

106
describe('CommitBox', () => {
11-
describe('#checkReadyForSubmit()', () => {
12-
it('should update commit box state to be ready when changes are staged', () => {
7+
describe('#constructor()', () => {
8+
it('should return a new instance', () => {
139
const box = new CommitBox({
1410
onCommit: async () => {},
15-
hasFiles: true
11+
hasFiles: false
1612
});
17-
18-
// TODO: this sort of testing should be performed during UI/UX testing, not unit testing
19-
let actual = box._commitButtonStyle(true);
20-
21-
let expected = classes(
22-
stagedCommitButtonStyle,
23-
stagedCommitButtonReadyStyle
24-
);
25-
expect(actual).toEqual(expected);
13+
expect(box).toBeInstanceOf(CommitBox);
2614
});
2715

28-
it('should update commit box state to be disabled when no changes are staged', () => {
16+
it('should set correct default commit message values', () => {
2917
const box = new CommitBox({
3018
onCommit: async () => {},
31-
hasFiles: true
19+
hasFiles: false
3220
});
33-
34-
// TODO: this sort of testing should be performed during UI/UX testing, not unit testing
35-
let actual = box._commitButtonStyle(false);
36-
let expected = classes(
37-
stagedCommitButtonStyle,
38-
stagedCommitButtonDisabledStyle
39-
);
40-
expect(actual).toEqual(expected);
21+
expect(box.state.summary).toEqual('');
22+
expect(box.state.description).toEqual('');
4123
});
24+
});
4225

43-
it('should be ready to commit with a message set', () => {
44-
const box = new CommitBox({
26+
describe('#render()', () => {
27+
it('should display placeholder text for the commit message summary', () => {
28+
const props = {
4529
onCommit: async () => {},
46-
hasFiles: true
47-
});
48-
// can't use setState here, since the box hasn't actually mounted
49-
box.state = { value: 'message' };
30+
hasFiles: false
31+
};
32+
const component = shallow(<CommitBox {...props} />);
33+
const node = component.find('input[type="text"]').first();
34+
expect(node.prop('placeholder')).toEqual('Summary (required)');
35+
});
5036

51-
// TODO: this sort of testing should be performed during UI/UX testing, not unit testing
52-
let actual = box._commitButtonStyle(true);
53-
let expected = stagedCommitButtonStyle;
54-
expect(actual).toEqual(expected);
37+
it('should display placeholder text for the commit message description', () => {
38+
const props = {
39+
onCommit: async () => {},
40+
hasFiles: false
41+
};
42+
const component = shallow(<CommitBox {...props} />);
43+
const node = component.find('TextareaAutosize').first();
44+
expect(node.prop('placeholder')).toEqual('Description');
5545
});
5646
});
5747
});

0 commit comments

Comments
 (0)