@@ -6,6 +6,9 @@ describe('FlexToolBar', function () {
6
6
await atom . packages . activatePackage ( 'tool-bar' ) ;
7
7
await atom . packages . activatePackage ( 'flex-tool-bar' ) ;
8
8
} ) ;
9
+ afterEach ( async function ( ) {
10
+ await atom . reset ( ) ;
11
+ } ) ;
9
12
10
13
describe ( 'activate' , function ( ) {
11
14
it ( 'should store grammar' , async function ( ) {
@@ -180,29 +183,97 @@ describe('FlexToolBar', function () {
180
183
} ) ;
181
184
182
185
describe ( 'correct project config path' , function ( ) {
183
- beforeAll ( function ( ) {
186
+ beforeEach ( function ( ) {
184
187
flexToolBar . configFilePath = path . resolve ( __dirname , './fixtures/config/config.json' ) ;
185
188
} ) ;
186
189
187
- it ( 'should load toolbar.cson from specified path' , function ( ) {
190
+ it ( 'should load toolbar.cson from specified path' , async function ( ) {
188
191
atom . config . set ( 'flex-tool-bar.toolBarProjectConfigurationFilePath' , '.' ) ;
189
- flexToolBar . resolveProjectConfigPath ( ) ;
192
+ await atom . workspace . open ( path . join ( __dirname , 'fixtures/sample.js' ) ) ;
190
193
expect ( flexToolBar . projectToolbarConfigPath ) . toBe ( path . resolve ( __dirname , './fixtures/toolbar.cson' ) ) ;
191
194
} ) ;
192
195
193
- it ( 'should load specified config file' , function ( ) {
196
+ it ( 'should load specified config file' , async function ( ) {
194
197
atom . config . set ( 'flex-tool-bar.toolBarProjectConfigurationFilePath' , './config/config.cson' ) ;
195
- flexToolBar . resolveProjectConfigPath ( ) ;
198
+ await atom . workspace . open ( path . join ( __dirname , 'fixtures/sample.js' ) ) ;
196
199
expect ( flexToolBar . projectToolbarConfigPath ) . toBe ( path . resolve ( __dirname , './fixtures/config/config.cson' ) ) ;
197
200
} ) ;
198
201
199
- it ( 'should not load if path equals global config file' , function ( ) {
202
+ it ( 'should not load if path equals global config file' , async function ( ) {
200
203
atom . config . set ( 'flex-tool-bar.toolBarProjectConfigurationFilePath' , './config/config.json' ) ;
201
- flexToolBar . resolveProjectConfigPath ( ) ;
204
+ await atom . workspace . open ( path . join ( __dirname , 'fixtures/sample.js' ) ) ;
202
205
expect ( flexToolBar . projectToolbarConfigPath ) . toBe ( null ) ;
203
206
} ) ;
204
207
} ) ;
205
208
209
+ describe ( 'persistent project tool bar' , function ( ) {
210
+ beforeEach ( async function ( ) {
211
+ this . project1Config = path . join ( __dirname , 'fixtures/project1/toolbar.cson' ) ;
212
+ this . project2Config = path . join ( __dirname , 'fixtures/project2/toolbar.cson' ) ;
213
+ this . project1Sample = path . join ( __dirname , 'fixtures/project1/sample.js' ) ;
214
+ this . project2Sample = path . join ( __dirname , 'fixtures/project2/sample.js' ) ;
215
+ this . project3Sample = path . join ( __dirname , 'fixtures/project3/sample.js' ) ;
216
+ this . settingsView = 'atom://config/packages/flex-toolbar' ;
217
+
218
+ await atom . packages . activatePackage ( 'settings-view' ) ;
219
+ flexToolBar . projectToolbarConfigPath = null ;
220
+ atom . project . setPaths ( [
221
+ path . join ( __dirname , 'fixtures/project1/' ) ,
222
+ path . join ( __dirname , 'fixtures/project2/' ) ,
223
+ path . join ( __dirname , 'fixtures/project3/' ) ,
224
+ ] ) ;
225
+ } ) ;
226
+ it ( 'should not persistent when an editor is open that does not have a project config' , async function ( ) {
227
+ atom . config . set ( 'flex-tool-bar.persistentProjectToolBar' , false ) ;
228
+
229
+ await atom . workspace . open ( this . project1Sample ) ;
230
+ expect ( flexToolBar . projectToolbarConfigPath ) . toBe ( this . project1Config ) ;
231
+
232
+ await atom . workspace . open ( this . settingsView ) ;
233
+ expect ( flexToolBar . projectToolbarConfigPath ) . toBeNull ( ) ;
234
+
235
+ await atom . workspace . open ( this . project3Sample ) ;
236
+ expect ( flexToolBar . projectToolbarConfigPath ) . toBeNull ( ) ;
237
+
238
+ await atom . workspace . open ( this . project2Sample ) ;
239
+ expect ( flexToolBar . projectToolbarConfigPath ) . toBe ( this . project2Config ) ;
240
+
241
+ await atom . workspace . open ( this . settingsView ) ;
242
+ expect ( flexToolBar . projectToolbarConfigPath ) . toBeNull ( ) ;
243
+
244
+ await atom . workspace . open ( this . project3Sample ) ;
245
+ expect ( flexToolBar . projectToolbarConfigPath ) . toBeNull ( ) ;
246
+
247
+ await atom . workspace . open ( this . project1Sample ) ;
248
+ expect ( flexToolBar . projectToolbarConfigPath ) . toBe ( this . project1Config ) ;
249
+ } ) ;
250
+
251
+ it ( 'should persistent when an editor is open that does not have a project config' , async function ( ) {
252
+ atom . config . set ( 'flex-tool-bar.persistentProjectToolBar' , true ) ;
253
+
254
+ await atom . workspace . open ( this . project1Sample ) ;
255
+ expect ( flexToolBar . projectToolbarConfigPath ) . toBe ( this . project1Config ) ;
256
+
257
+ await atom . workspace . open ( this . settingsView ) ;
258
+ expect ( flexToolBar . projectToolbarConfigPath ) . toBe ( this . project1Config ) ;
259
+
260
+ await atom . workspace . open ( this . project3Sample ) ;
261
+ expect ( flexToolBar . projectToolbarConfigPath ) . toBe ( this . project1Config ) ;
262
+
263
+ await atom . workspace . open ( this . project2Sample ) ;
264
+ expect ( flexToolBar . projectToolbarConfigPath ) . toBe ( this . project2Config ) ;
265
+
266
+ await atom . workspace . open ( this . settingsView ) ;
267
+ expect ( flexToolBar . projectToolbarConfigPath ) . toBe ( this . project2Config ) ;
268
+
269
+ await atom . workspace . open ( this . project3Sample ) ;
270
+ expect ( flexToolBar . projectToolbarConfigPath ) . toBe ( this . project2Config ) ;
271
+
272
+ await atom . workspace . open ( this . project1Sample ) ;
273
+ expect ( flexToolBar . projectToolbarConfigPath ) . toBe ( this . project1Config ) ;
274
+ } ) ;
275
+ } ) ;
276
+
206
277
if ( ! global . headless ) {
207
278
// show linting errors in atom test window
208
279
describe ( 'linting' , function ( ) {
0 commit comments