@@ -47,9 +47,6 @@ const BRANCHES = [
47
47
48
48
async function createModel ( ) {
49
49
const model = new GitExtension ( '/server/root' ) ;
50
-
51
- jest . spyOn ( model , 'branches' , 'get' ) . mockReturnValue ( BRANCHES ) ;
52
- jest . spyOn ( model , 'currentBranch' , 'get' ) . mockReturnValue ( BRANCHES [ 0 ] ) ;
53
50
model . pathRepository = '/path/to/repo' ;
54
51
55
52
await model . ready ;
@@ -82,6 +79,8 @@ describe('BranchMenu', () => {
82
79
describe ( 'constructor' , ( ) => {
83
80
it ( 'should return a new instance' , ( ) => {
84
81
const props = {
82
+ currentBranch : BRANCHES [ 0 ] . name ,
83
+ branches : BRANCHES ,
85
84
model : model ,
86
85
branching : false ,
87
86
logger : new Logger ( ) ,
@@ -92,6 +91,8 @@ describe('BranchMenu', () => {
92
91
93
92
it ( 'should set the default menu filter to an empty string' , ( ) => {
94
93
const props = {
94
+ currentBranch : BRANCHES [ 0 ] . name ,
95
+ branches : BRANCHES ,
95
96
model : model ,
96
97
branching : false ,
97
98
logger : new Logger ( ) ,
@@ -102,6 +103,8 @@ describe('BranchMenu', () => {
102
103
103
104
it ( 'should set the default flag indicating whether to show a dialog to create a new branch to `false`' , ( ) => {
104
105
const props = {
106
+ currentBranch : BRANCHES [ 0 ] . name ,
107
+ branches : BRANCHES ,
105
108
model : model ,
106
109
branching : false ,
107
110
logger : new Logger ( ) ,
@@ -114,6 +117,8 @@ describe('BranchMenu', () => {
114
117
describe ( 'render' , ( ) => {
115
118
it ( 'should display placeholder text for the menu filter' , ( ) => {
116
119
const props = {
120
+ currentBranch : BRANCHES [ 0 ] . name ,
121
+ branches : BRANCHES ,
117
122
model : model ,
118
123
branching : false ,
119
124
logger : new Logger ( ) ,
@@ -125,6 +130,8 @@ describe('BranchMenu', () => {
125
130
126
131
it ( 'should set a `title` attribute on the input element to filter a branch menu' , ( ) => {
127
132
const props = {
133
+ currentBranch : BRANCHES [ 0 ] . name ,
134
+ branches : BRANCHES ,
128
135
model : model ,
129
136
branching : false ,
130
137
logger : new Logger ( ) ,
@@ -136,6 +143,8 @@ describe('BranchMenu', () => {
136
143
137
144
it ( 'should display a button to clear the menu filter once a filter is provided' , ( ) => {
138
145
const props = {
146
+ currentBranch : BRANCHES [ 0 ] . name ,
147
+ branches : BRANCHES ,
139
148
model : model ,
140
149
branching : false ,
141
150
logger : new Logger ( ) ,
@@ -150,6 +159,8 @@ describe('BranchMenu', () => {
150
159
151
160
it ( 'should set a `title` on the button to clear the menu filter' , ( ) => {
152
161
const props = {
162
+ currentBranch : BRANCHES [ 0 ] . name ,
163
+ branches : BRANCHES ,
153
164
model : model ,
154
165
branching : false ,
155
166
logger : new Logger ( ) ,
@@ -167,6 +178,8 @@ describe('BranchMenu', () => {
167
178
168
179
it ( 'should display a button to create a new branch' , ( ) => {
169
180
const props = {
181
+ currentBranch : BRANCHES [ 0 ] . name ,
182
+ branches : BRANCHES ,
170
183
model : model ,
171
184
branching : false ,
172
185
logger : new Logger ( ) ,
@@ -178,6 +191,8 @@ describe('BranchMenu', () => {
178
191
179
192
it ( 'should set a `title` attribute on the button to create a new branch' , ( ) => {
180
193
const props = {
194
+ currentBranch : BRANCHES [ 0 ] . name ,
195
+ branches : BRANCHES ,
181
196
model : model ,
182
197
branching : false ,
183
198
logger : new Logger ( ) ,
@@ -189,14 +204,16 @@ describe('BranchMenu', () => {
189
204
190
205
it ( 'should display a list of branches' , ( ) => {
191
206
const props = {
207
+ currentBranch : BRANCHES [ 0 ] . name ,
208
+ branches : BRANCHES ,
192
209
model : model ,
193
210
branching : false ,
194
211
logger : new Logger ( ) ,
195
212
} ;
196
213
const component = render ( < BranchMenu { ...props } /> ) ;
197
214
const nodes = component . find ( `.${ listItemClass } ` ) ;
198
215
199
- const branches = model . branches ;
216
+ const branches = BRANCHES ;
200
217
expect ( nodes . length ) . toEqual ( branches . length ) ;
201
218
202
219
// Should contain the branch names...
@@ -209,14 +226,16 @@ describe('BranchMenu', () => {
209
226
210
227
it ( 'should set a `title` attribute for each displayed branch' , ( ) => {
211
228
const props = {
229
+ currentBranch : BRANCHES [ 0 ] . name ,
230
+ branches : BRANCHES ,
212
231
model : model ,
213
232
branching : false ,
214
233
logger : new Logger ( ) ,
215
234
} ;
216
235
const component = render ( < BranchMenu { ...props } /> ) ;
217
236
const nodes = component . find ( `.${ listItemClass } ` ) ;
218
237
219
- const branches = model . branches ;
238
+ const branches = BRANCHES ;
220
239
expect ( nodes . length ) . toEqual ( branches . length ) ;
221
240
222
241
for ( let i = 0 ; i < branches . length ; i ++ ) {
@@ -226,6 +245,8 @@ describe('BranchMenu', () => {
226
245
227
246
it ( 'should not, by default, show a dialog to create a new branch' , ( ) => {
228
247
const props = {
248
+ currentBranch : BRANCHES [ 0 ] . name ,
249
+ branches : BRANCHES ,
229
250
model : model ,
230
251
branching : false ,
231
252
logger : new Logger ( ) ,
@@ -237,6 +258,8 @@ describe('BranchMenu', () => {
237
258
238
259
it ( 'should show a dialog to create a new branch when the flag indicating whether to show the dialog is `true`' , ( ) => {
239
260
const props = {
261
+ currentBranch : BRANCHES [ 0 ] . name ,
262
+ branches : BRANCHES ,
240
263
model : model ,
241
264
branching : false ,
242
265
logger : new Logger ( ) ,
@@ -255,6 +278,8 @@ describe('BranchMenu', () => {
255
278
const spy = jest . spyOn ( GitExtension . prototype , 'checkout' ) ;
256
279
257
280
const props = {
281
+ currentBranch : BRANCHES [ 0 ] . name ,
282
+ branches : BRANCHES ,
258
283
model : model ,
259
284
branching : false ,
260
285
logger : new Logger ( ) ,
@@ -271,6 +296,8 @@ describe('BranchMenu', () => {
271
296
const spy = jest . spyOn ( GitExtension . prototype , 'checkout' ) ;
272
297
273
298
const props = {
299
+ currentBranch : BRANCHES [ 0 ] . name ,
300
+ branches : BRANCHES ,
274
301
model : model ,
275
302
branching : true ,
276
303
logger : new Logger ( ) ,
@@ -293,6 +320,8 @@ describe('BranchMenu', () => {
293
320
const spy = jest . spyOn ( GitExtension . prototype , 'checkout' ) ;
294
321
295
322
const props = {
323
+ currentBranch : BRANCHES [ 0 ] . name ,
324
+ branches : BRANCHES ,
296
325
model : model ,
297
326
branching : false ,
298
327
logger : new Logger ( ) ,
@@ -311,6 +340,8 @@ describe('BranchMenu', () => {
311
340
const spy = jest . spyOn ( GitExtension . prototype , 'checkout' ) ;
312
341
313
342
const props = {
343
+ currentBranch : BRANCHES [ 0 ] . name ,
344
+ branches : BRANCHES ,
314
345
model : model ,
315
346
branching : true ,
316
347
logger : new Logger ( ) ,
0 commit comments