1
- import * as React from 'react' ;
2
- import 'jest' ;
1
+ import { refreshIcon } from '@jupyterlab/ui-components' ;
3
2
import { shallow } from 'enzyme' ;
4
- import { GitExtension } from '../../src/model' ;
5
- import * as git from '../../src/git' ;
3
+ import 'jest' ;
4
+ import * as React from 'react' ;
5
+ import { ActionButton } from '../../src/components/ActionButton' ;
6
6
import { Toolbar } from '../../src/components/Toolbar' ;
7
+ import * as git from '../../src/git' ;
8
+ import { GitExtension } from '../../src/model' ;
9
+ import { pullIcon , pushIcon } from '../../src/style/icons' ;
7
10
import {
8
- pullButtonClass ,
9
- pushButtonClass ,
10
- refreshButtonClass ,
11
+ toolbarButtonClass ,
11
12
toolbarMenuButtonClass
12
13
} from '../../src/style/Toolbar' ;
13
14
@@ -133,8 +134,9 @@ describe('Toolbar', () => {
133
134
refresh : async ( ) => { }
134
135
} ;
135
136
const node = shallow ( < Toolbar { ...props } /> ) ;
136
- const nodes = node . find ( `.${ pullButtonClass } ` ) ;
137
-
137
+ const nodes = node
138
+ . find ( ActionButton )
139
+ . findWhere ( n => n . prop ( 'icon' ) === pullIcon ) ;
138
140
expect ( nodes . length ) . toEqual ( 1 ) ;
139
141
} ) ;
140
142
@@ -145,7 +147,10 @@ describe('Toolbar', () => {
145
147
refresh : async ( ) => { }
146
148
} ;
147
149
const node = shallow ( < Toolbar { ...props } /> ) ;
148
- const button = node . find ( `.${ pullButtonClass } ` ) . first ( ) ;
150
+ const button = node
151
+ . find ( ActionButton )
152
+ . findWhere ( n => n . prop ( 'icon' ) === pullIcon )
153
+ . first ( ) ;
149
154
150
155
expect ( button . prop ( 'title' ) ) . toEqual ( 'Pull latest changes' ) ;
151
156
} ) ;
@@ -157,8 +162,9 @@ describe('Toolbar', () => {
157
162
refresh : async ( ) => { }
158
163
} ;
159
164
const node = shallow ( < Toolbar { ...props } /> ) ;
160
- const nodes = node . find ( `.${ pushButtonClass } ` ) ;
161
-
165
+ const nodes = node
166
+ . find ( ActionButton )
167
+ . findWhere ( n => n . prop ( 'icon' ) === pushIcon ) ;
162
168
expect ( nodes . length ) . toEqual ( 1 ) ;
163
169
} ) ;
164
170
@@ -169,7 +175,10 @@ describe('Toolbar', () => {
169
175
refresh : async ( ) => { }
170
176
} ;
171
177
const node = shallow ( < Toolbar { ...props } /> ) ;
172
- const button = node . find ( `.${ pushButtonClass } ` ) . first ( ) ;
178
+ const button = node
179
+ . find ( ActionButton )
180
+ . findWhere ( n => n . prop ( 'icon' ) === pushIcon )
181
+ . first ( ) ;
173
182
174
183
expect ( button . prop ( 'title' ) ) . toEqual ( 'Push committed changes' ) ;
175
184
} ) ;
@@ -181,7 +190,9 @@ describe('Toolbar', () => {
181
190
refresh : async ( ) => { }
182
191
} ;
183
192
const node = shallow ( < Toolbar { ...props } /> ) ;
184
- const nodes = node . find ( `.${ refreshButtonClass } ` ) ;
193
+ const nodes = node
194
+ . find ( ActionButton )
195
+ . findWhere ( n => n . prop ( 'icon' ) === refreshIcon ) ;
185
196
186
197
expect ( nodes . length ) . toEqual ( 1 ) ;
187
198
} ) ;
@@ -193,7 +204,7 @@ describe('Toolbar', () => {
193
204
refresh : async ( ) => { }
194
205
} ;
195
206
const node = shallow ( < Toolbar { ...props } /> ) ;
196
- const button = node . find ( `. ${ refreshButtonClass } ` ) . first ( ) ;
207
+ const button = node . find ( ActionButton ) . last ( ) ;
197
208
198
209
expect ( button . prop ( 'title' ) ) . toEqual (
199
210
'Refresh the repository to detect local and remote changes'
@@ -309,7 +320,7 @@ describe('Toolbar', () => {
309
320
refresh : async ( ) => { }
310
321
} ;
311
322
const node = shallow ( < Toolbar { ...props } /> ) ;
312
- const button = node . find ( `.${ pullButtonClass } ` ) ;
323
+ const button = node . find ( `.${ toolbarButtonClass } ` ) . first ( ) ;
313
324
314
325
button . simulate ( 'click' ) ;
315
326
expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -338,7 +349,7 @@ describe('Toolbar', () => {
338
349
refresh : async ( ) => { }
339
350
} ;
340
351
const node = shallow ( < Toolbar { ...props } /> ) ;
341
- const button = node . find ( `.${ pushButtonClass } ` ) ;
352
+ const button = node . find ( `.${ toolbarButtonClass } ` ) . at ( 1 ) ;
342
353
343
354
button . simulate ( 'click' ) ;
344
355
expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -367,7 +378,7 @@ describe('Toolbar', () => {
367
378
refresh : spy
368
379
} ;
369
380
const node = shallow ( < Toolbar { ...props } /> ) ;
370
- const button = node . find ( `.${ refreshButtonClass } ` ) ;
381
+ const button = node . find ( `.${ toolbarButtonClass } ` ) . last ( ) ;
371
382
372
383
button . simulate ( 'click' ) ;
373
384
expect ( spy ) . toHaveBeenCalledTimes ( 1 ) ;
0 commit comments