@@ -15,7 +15,13 @@ describe('GithubTabHeaderView', function() {
15
15
function build ( options = { } ) {
16
16
const props = {
17
17
user : nullAuthor ,
18
+ workdir : null ,
18
19
workdirs : createWorkdirs ( [ ] ) ,
20
+ contextLocked : false ,
21
+ changingWorkDir : false ,
22
+ changingLock : false ,
23
+ handleWorkDirChange : ( ) => { } ,
24
+ handleLockToggle : ( ) => { } ,
19
25
...options ,
20
26
} ;
21
27
return shallow ( < GithubTabHeaderView { ...props } /> ) ;
@@ -29,7 +35,7 @@ describe('GithubTabHeaderView', function() {
29
35
30
36
beforeEach ( function ( ) {
31
37
select = sinon . spy ( ) ;
32
- wrapper = build ( { handleWorkDirSelect : select , workdirs : createWorkdirs ( paths ) , workdir : path2 } ) ;
38
+ wrapper = build ( { handleWorkDirChange : select , workdirs : createWorkdirs ( paths ) , workdir : path2 } ) ;
33
39
} ) ;
34
40
35
41
it ( 'renders an option for all given working directories' , function ( ) {
@@ -49,6 +55,42 @@ describe('GithubTabHeaderView', function() {
49
55
} ) ;
50
56
} ) ;
51
57
58
+ describe ( 'context lock control' , function ( ) {
59
+ it ( 'renders locked when the lock is engaged' , function ( ) {
60
+ const wrapper = build ( { contextLocked : true } ) ;
61
+
62
+ assert . isTrue ( wrapper . exists ( 'Octicon[icon="lock"]' ) ) ;
63
+ } ) ;
64
+
65
+ it ( 'renders unlocked when the lock is disengaged' , function ( ) {
66
+ const wrapper = build ( { contextLocked : false } ) ;
67
+
68
+ assert . isTrue ( wrapper . exists ( 'Octicon[icon="globe"]' ) ) ;
69
+ } ) ;
70
+
71
+ it ( 'calls handleLockToggle when the lock is clicked' , function ( ) {
72
+ const handleLockToggle = sinon . spy ( ) ;
73
+ const wrapper = build ( { handleLockToggle} ) ;
74
+
75
+ wrapper . find ( 'button' ) . simulate ( 'click' ) ;
76
+ assert . isTrue ( handleLockToggle . called ) ;
77
+ } ) ;
78
+ } ) ;
79
+
80
+ describe ( 'when changes are in progress' , function ( ) {
81
+ it ( 'disables the workdir select while the workdir is changing' , function ( ) {
82
+ const wrapper = build ( { changingWorkDir : true } ) ;
83
+
84
+ assert . isTrue ( wrapper . find ( 'select' ) . prop ( 'disabled' ) ) ;
85
+ } ) ;
86
+
87
+ it ( 'disables the context lock toggle while the context lock is changing' , function ( ) {
88
+ const wrapper = build ( { changingLock : true } ) ;
89
+
90
+ assert . isTrue ( wrapper . find ( 'button' ) . prop ( 'disabled' ) ) ;
91
+ } )
92
+ } ) ;
93
+
52
94
describe ( 'with falsish props' , function ( ) {
53
95
let wrapper ;
54
96
0 commit comments