1
- import * as React from 'react' ;
2
- import 'jest' ;
3
- import { shallow } from 'enzyme' ;
4
- import { CommitBox } from '../../src/components/CommitBox' ;
5
- import { CommandRegistry } from '@lumino/commands' ;
6
1
import { nullTranslator } from '@jupyterlab/translation' ;
2
+ import { CommandRegistry } from '@lumino/commands' ;
3
+ import { shallow } from 'enzyme' ;
4
+ import 'jest' ;
5
+ import * as React from 'react' ;
6
+ import { CommitBox } from '../../src/components/CommitBox' ;
7
7
import { CommandIDs } from '../../src/tokens' ;
8
8
9
9
describe ( 'CommitBox' , ( ) => {
10
-
11
- const defaultCommands = new CommandRegistry ( )
10
+ const defaultCommands = new CommandRegistry ( ) ;
12
11
defaultCommands . addKeyBinding ( {
13
12
keys : [ 'Accel Enter' ] ,
14
13
command : CommandIDs . gitSubmitCommand ,
15
14
selector : '.jp-git-CommitBox'
16
- } )
15
+ } ) ;
17
16
18
17
const trans = nullTranslator . load ( 'jupyterlab-git' ) ;
19
18
@@ -23,7 +22,8 @@ describe('CommitBox', () => {
23
22
onCommit : async ( ) => { } ,
24
23
hasFiles : false ,
25
24
commands : defaultCommands ,
26
- trans : trans
25
+ trans : trans ,
26
+ label : 'Commit'
27
27
} ) ;
28
28
expect ( box ) . toBeInstanceOf ( CommitBox ) ;
29
29
} ) ;
@@ -33,7 +33,8 @@ describe('CommitBox', () => {
33
33
onCommit : async ( ) => { } ,
34
34
hasFiles : false ,
35
35
commands : defaultCommands ,
36
- trans : trans
36
+ trans : trans ,
37
+ label : 'Commit'
37
38
} ) ;
38
39
expect ( box . state . summary ) . toEqual ( '' ) ;
39
40
} ) ;
@@ -43,7 +44,8 @@ describe('CommitBox', () => {
43
44
onCommit : async ( ) => { } ,
44
45
hasFiles : false ,
45
46
commands : defaultCommands ,
46
- trans : trans
47
+ trans : trans ,
48
+ label : 'Commit'
47
49
} ) ;
48
50
expect ( box . state . description ) . toEqual ( '' ) ;
49
51
} ) ;
@@ -55,37 +57,44 @@ describe('CommitBox', () => {
55
57
onCommit : async ( ) => { } ,
56
58
hasFiles : false ,
57
59
commands : defaultCommands ,
58
- trans : trans
60
+ trans : trans ,
61
+ label : 'Commit'
59
62
} ;
60
63
const component = shallow ( < CommitBox { ...props } /> ) ;
61
64
const node = component . find ( 'input[type="text"]' ) . first ( ) ;
62
- expect ( node . prop ( 'placeholder' ) ) . toEqual ( 'Summary (Ctrl+Enter to commit)' ) ;
65
+ expect ( node . prop ( 'placeholder' ) ) . toEqual (
66
+ 'Summary (Ctrl+Enter to commit)'
67
+ ) ;
63
68
} ) ;
64
69
65
70
it ( 'should adjust placeholder text for the commit message summary when keybinding changes' , ( ) => {
66
- const adjustedCommands = new CommandRegistry ( )
71
+ const adjustedCommands = new CommandRegistry ( ) ;
67
72
adjustedCommands . addKeyBinding ( {
68
73
keys : [ 'Shift Enter' ] ,
69
74
command : CommandIDs . gitSubmitCommand ,
70
75
selector : '.jp-git-CommitBox'
71
- } )
76
+ } ) ;
72
77
const props = {
73
78
onCommit : async ( ) => { } ,
74
79
hasFiles : false ,
75
80
commands : adjustedCommands ,
76
- trans : trans
81
+ trans : trans ,
82
+ label : 'Commit'
77
83
} ;
78
84
const component = shallow ( < CommitBox { ...props } /> ) ;
79
85
const node = component . find ( 'input[type="text"]' ) . first ( ) ;
80
- expect ( node . prop ( 'placeholder' ) ) . toEqual ( 'Summary (Shift+Enter to commit)' ) ;
86
+ expect ( node . prop ( 'placeholder' ) ) . toEqual (
87
+ 'Summary (Shift+Enter to commit)'
88
+ ) ;
81
89
} ) ;
82
90
83
91
it ( 'should set a `title` attribute on the input element to provide a commit message summary' , ( ) => {
84
92
const props = {
85
93
onCommit : async ( ) => { } ,
86
94
hasFiles : false ,
87
95
commands : defaultCommands ,
88
- trans : trans
96
+ trans : trans ,
97
+ label : 'Commit'
89
98
} ;
90
99
const component = shallow ( < CommitBox { ...props } /> ) ;
91
100
const node = component . find ( 'input[type="text"]' ) . first ( ) ;
@@ -97,7 +106,8 @@ describe('CommitBox', () => {
97
106
onCommit : async ( ) => { } ,
98
107
hasFiles : false ,
99
108
commands : defaultCommands ,
100
- trans : trans
109
+ trans : trans ,
110
+ label : 'Commit'
101
111
} ;
102
112
const component = shallow ( < CommitBox { ...props } /> ) ;
103
113
const node = component . find ( 'TextareaAutosize' ) . first ( ) ;
@@ -109,7 +119,8 @@ describe('CommitBox', () => {
109
119
onCommit : async ( ) => { } ,
110
120
hasFiles : false ,
111
121
commands : defaultCommands ,
112
- trans : trans
122
+ trans : trans ,
123
+ label : 'Commit'
113
124
} ;
114
125
const component = shallow ( < CommitBox { ...props } /> ) ;
115
126
const node = component . find ( 'TextareaAutosize' ) . first ( ) ;
@@ -121,7 +132,8 @@ describe('CommitBox', () => {
121
132
onCommit : async ( ) => { } ,
122
133
hasFiles : false ,
123
134
commands : defaultCommands ,
124
- trans : trans
135
+ trans : trans ,
136
+ label : 'Commit'
125
137
} ;
126
138
const component = shallow ( < CommitBox { ...props } /> ) ;
127
139
const node = component . find ( 'input[type="button"]' ) . first ( ) ;
@@ -133,7 +145,8 @@ describe('CommitBox', () => {
133
145
onCommit : async ( ) => { } ,
134
146
hasFiles : false ,
135
147
commands : defaultCommands ,
136
- trans : trans
148
+ trans : trans ,
149
+ label : 'Commit'
137
150
} ;
138
151
const component = shallow ( < CommitBox { ...props } /> ) ;
139
152
const node = component . find ( 'input[type="button"]' ) . first ( ) ;
@@ -145,7 +158,8 @@ describe('CommitBox', () => {
145
158
onCommit : async ( ) => { } ,
146
159
hasFiles : false ,
147
160
commands : defaultCommands ,
148
- trans : trans
161
+ trans : trans ,
162
+ label : 'Commit'
149
163
} ;
150
164
const component = shallow ( < CommitBox { ...props } /> ) ;
151
165
const node = component . find ( 'input[type="button"]' ) . first ( ) ;
@@ -158,7 +172,8 @@ describe('CommitBox', () => {
158
172
onCommit : async ( ) => { } ,
159
173
hasFiles : true ,
160
174
commands : defaultCommands ,
161
- trans : trans
175
+ trans : trans ,
176
+ label : 'Commit'
162
177
} ;
163
178
const component = shallow ( < CommitBox { ...props } /> ) ;
164
179
const node = component . find ( 'input[type="button"]' ) . first ( ) ;
@@ -171,7 +186,8 @@ describe('CommitBox', () => {
171
186
onCommit : async ( ) => { } ,
172
187
hasFiles : true ,
173
188
commands : defaultCommands ,
174
- trans : trans
189
+ trans : trans ,
190
+ label : 'Commit'
175
191
} ;
176
192
const component = shallow ( < CommitBox { ...props } /> ) ;
177
193
component . setState ( {
0 commit comments