|
| 1 | +import * as React from 'react'; |
1 | 2 | import 'jest';
|
| 3 | +import { shallow } from 'enzyme'; |
2 | 4 | import { CommitBox } from '../../src/components/CommitBox';
|
3 |
| -import { classes } from 'typestyle'; |
4 |
| -import { |
5 |
| - stagedCommitButtonStyle, |
6 |
| - stagedCommitButtonReadyStyle, |
7 |
| - stagedCommitButtonDisabledStyle |
8 |
| -} from '../../src/style/BranchHeaderStyle'; |
9 | 5 |
|
10 | 6 | 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', () => { |
13 | 9 | const box = new CommitBox({
|
14 | 10 | onCommit: async () => {},
|
15 |
| - hasFiles: true |
| 11 | + hasFiles: false |
16 | 12 | });
|
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); |
26 | 14 | });
|
27 | 15 |
|
28 |
| - it('should update commit box state to be disabled when no changes are staged', () => { |
| 16 | + it('should set correct default commit message values', () => { |
29 | 17 | const box = new CommitBox({
|
30 | 18 | onCommit: async () => {},
|
31 |
| - hasFiles: true |
| 19 | + hasFiles: false |
32 | 20 | });
|
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(''); |
41 | 23 | });
|
| 24 | + }); |
42 | 25 |
|
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 = { |
45 | 29 | 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 | + }); |
50 | 36 |
|
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'); |
55 | 45 | });
|
56 | 46 | });
|
57 | 47 | });
|
0 commit comments