@@ -91,17 +91,21 @@ describe('CommitViewController', function() {
91
91
} ) ;
92
92
93
93
describe ( 'committing' , function ( ) {
94
- let controller , resolve , reject ;
94
+ let controller , resolve , reject , workdirPath ;
95
95
96
96
beforeEach ( async function ( ) {
97
- const workdirPath = await cloneRepository ( 'three-files' ) ;
97
+ workdirPath = await cloneRepository ( 'three-files' ) ;
98
98
const repository = await buildRepository ( workdirPath ) ;
99
99
const commit = ( ) => new Promise ( ( resolver , rejecter ) => {
100
100
resolve = resolver ;
101
101
reject = rejecter ;
102
102
} ) ;
103
103
104
- controller = new CommitViewController ( { commandRegistry, notificationManager, lastCommit, repository, commit} ) ;
104
+ controller = new CommitViewController ( { workspace, commandRegistry, notificationManager, grammars, lastCommit, repository, commit} ) ;
105
+ } ) ;
106
+
107
+ afterEach ( ( ) => {
108
+ controller . destroy ( ) ;
105
109
} ) ;
106
110
107
111
it ( 'clears the regular and amending commit messages' , async function ( ) {
@@ -133,76 +137,62 @@ describe('CommitViewController', function() {
133
137
assert . equal ( controller . regularCommitMessage , 'regular' ) ;
134
138
assert . equal ( controller . amendingCommitMessage , 'amending' ) ;
135
139
} ) ;
136
- } ) ;
137
-
138
- describe ( 'toggling between commit box and commit editor' , function ( ) {
139
- let controller , workdirPath ;
140
- beforeEach ( async ( ) => {
141
- workdirPath = await cloneRepository ( 'three-files' ) ;
142
- const repository = await buildRepository ( workdirPath ) ;
143
-
144
- controller = new CommitViewController ( {
145
- workspace, commandRegistry, notificationManager, grammars, lastCommit, repository,
146
- } ) ;
147
- } ) ;
148
-
149
- afterEach ( ( ) => {
150
- controller . destroy ( ) ;
151
- } ) ;
152
140
153
- it ( 'transfers the commit message contents' , async function ( ) {
154
- controller . refs . commitView . editor . setText ( 'message in box' ) ;
155
-
156
- commandRegistry . dispatch ( atomEnvironment . views . getView ( workspace ) , 'github:edit-commit-message-in-editor' ) ;
157
- let editor ;
158
- await until ( ( ) => {
159
- editor = workspace . getActiveTextEditor ( ) ;
160
- if ( editor ) {
161
- return path . basename ( editor . getPath ( ) ) === 'ATOM_COMMIT_EDITMSG' ;
162
- } else {
163
- return false ;
164
- }
141
+ describe ( 'toggling between commit box and commit editor' , function ( ) {
142
+ it ( 'transfers the commit message contents' , async function ( ) {
143
+ controller . refs . commitView . editor . setText ( 'message in box' ) ;
144
+
145
+ commandRegistry . dispatch ( atomEnvironment . views . getView ( workspace ) , 'github:edit-commit-message-in-editor' ) ;
146
+ let editor ;
147
+ await until ( ( ) => {
148
+ editor = workspace . getActiveTextEditor ( ) ;
149
+ if ( editor ) {
150
+ return path . basename ( editor . getPath ( ) ) === 'ATOM_COMMIT_EDITMSG' ;
151
+ } else {
152
+ return false ;
153
+ }
154
+ } ) ;
155
+ assert . equal ( editor . getText ( ) , 'message in box' ) ;
156
+
157
+ editor . setText ( 'message in editor' ) ;
158
+ editor . save ( ) ;
159
+ editor . destroy ( ) ;
160
+ await assert . async . equal ( controller . refs . commitView . editor . getText ( ) , 'message in editor' ) ;
165
161
} ) ;
166
- assert . equal ( editor . getText ( ) , 'message in box' ) ;
167
162
168
- editor . setText ( 'message in editor' ) ;
169
- editor . save ( ) ;
170
- editor . destroy ( ) ;
171
- await assert . async . equal ( controller . refs . commitView . editor . getText ( ) , 'message in editor' ) ;
172
- } ) ;
173
-
174
- it ( 'activates editor if already opened' , async function ( ) {
175
- commandRegistry . dispatch ( atomEnvironment . views . getView ( workspace ) , 'github:edit-commit-message-in-editor' ) ;
176
- let editor ;
177
- await until ( ( ) => {
178
- editor = workspace . getActiveTextEditor ( ) ;
179
- if ( editor ) {
180
- return path . basename ( editor . getPath ( ) ) === 'ATOM_COMMIT_EDITMSG' ;
181
- } else {
182
- return false ;
183
- }
163
+ it ( 'activates editor if already opened' , async function ( ) {
164
+ commandRegistry . dispatch ( atomEnvironment . views . getView ( workspace ) , 'github:edit-commit-message-in-editor' ) ;
165
+ let editor ;
166
+ await until ( ( ) => {
167
+ editor = workspace . getActiveTextEditor ( ) ;
168
+ if ( editor ) {
169
+ return path . basename ( editor . getPath ( ) ) === 'ATOM_COMMIT_EDITMSG' ;
170
+ } else {
171
+ return false ;
172
+ }
173
+ } ) ;
174
+
175
+ await workspace . open ( path . join ( workdirPath , 'a.txt' ) ) ;
176
+ workspace . getActivePane ( ) . splitRight ( ) ;
177
+ await workspace . open ( path . join ( workdirPath , 'b.txt' ) ) ;
178
+ assert . notEqual ( workspace . getActiveTextEditor ( ) , editor ) ;
179
+
180
+ commandRegistry . dispatch ( atomEnvironment . views . getView ( workspace ) , 'github:edit-commit-message-in-editor' ) ;
181
+ await assert . async . equal ( workspace . getActiveTextEditor ( ) , editor ) ;
184
182
} ) ;
185
183
186
- await workspace . open ( path . join ( workdirPath , 'a.txt' ) ) ;
187
- workspace . getActivePane ( ) . splitRight ( ) ;
188
- await workspace . open ( path . join ( workdirPath , 'b.txt' ) ) ;
189
- assert . notEqual ( workspace . getActiveTextEditor ( ) , editor ) ;
190
-
191
- commandRegistry . dispatch ( atomEnvironment . views . getView ( workspace ) , 'github:edit-commit-message-in-editor' ) ;
192
- await assert . async . equal ( workspace . getActiveTextEditor ( ) , editor ) ;
193
- } ) ;
194
-
195
- // TODO: Why is this not passing? get text.plain.null-grammar
196
- xit ( 'uses git commit grammar in the editor' , async function ( ) {
197
- commandRegistry . dispatch ( atomEnvironment . views . getView ( workspace ) , 'github:edit-commit-message-in-editor' ) ;
198
- let editor ;
199
- await until ( ( ) => {
200
- editor = workspace . getActiveTextEditor ( ) ;
201
- if ( editor ) {
202
- return editor . getGrammar ( ) . scopeName === COMMIT_GRAMMAR_SCOPE ;
203
- } else {
204
- return false ;
205
- }
184
+ // TODO: Why is this not passing? get text.plain.null-grammar
185
+ xit ( 'uses git commit grammar in the editor' , async function ( ) {
186
+ commandRegistry . dispatch ( atomEnvironment . views . getView ( workspace ) , 'github:edit-commit-message-in-editor' ) ;
187
+ let editor ;
188
+ await until ( ( ) => {
189
+ editor = workspace . getActiveTextEditor ( ) ;
190
+ if ( editor ) {
191
+ return editor . getGrammar ( ) . scopeName === COMMIT_GRAMMAR_SCOPE ;
192
+ } else {
193
+ return false ;
194
+ }
195
+ } ) ;
206
196
} ) ;
207
197
} ) ;
208
198
} ) ;
0 commit comments