Skip to content
This repository was archived by the owner on May 7, 2021. It is now read-only.

Commit 1109f08

Browse files
committed
Clean up some uncaught errors in specs
1 parent b2903e7 commit 1109f08

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

spec/autocomplete/gocodeprovider-spec.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ describe('gocodeprovider', () => {
157157
})
158158

159159
it('provides the exported types of the unimported package', () => {
160-
let suggestions = null
161160
waitsFor(() => provider.allPkgs.size > 0)
162161

163162
runs(() => {
@@ -176,9 +175,10 @@ describe('gocodeprovider', () => {
176175
})
177176

178177
runs(async () => {
179-
suggestions = await suggestionsPromise
180178
expect(provider.getSuggestions).toHaveBeenCalled()
181179
expect(provider.getSuggestions.calls.length).toBe(1)
180+
181+
const suggestions = await suggestionsPromise
182182
expect(suggestions).toBeTruthy()
183183
expect(suggestions.length).toBeGreaterThan(0)
184184
expect(suggestions[0]).toBeTruthy()
@@ -250,7 +250,6 @@ describe('gocodeprovider', () => {
250250
})
251251

252252
describe('when the go-plus-issue-307 file is opened', () => {
253-
let suggestions = null
254253
beforeEach(async () => {
255254
editor = await atom.workspace.open(
256255
'go-plus-issue-307' + path.sep + 'main.go'
@@ -262,7 +261,6 @@ describe('gocodeprovider', () => {
262261
runs(() => {
263262
editor.setCursorScreenPosition([13, 0])
264263
editor.insertText('\tSayHello("world")')
265-
suggestions = null
266264
suggestionsPromise = null
267265
advanceClock(completionDelay)
268266

@@ -280,10 +278,10 @@ describe('gocodeprovider', () => {
280278
})
281279

282280
runs(async () => {
283-
suggestions = await suggestionsPromise
284-
285281
expect(provider.getSuggestions).toHaveBeenCalled()
286282
expect(provider.getSuggestions.calls.length).toBe(1)
283+
284+
const suggestions = await suggestionsPromise
287285
expect(suggestions).toBeTruthy()
288286
expect(suggestions.length).toBeGreaterThan(0)
289287
expect(suggestions[0]).toBeTruthy()
@@ -299,7 +297,6 @@ describe('gocodeprovider', () => {
299297
runs(() => {
300298
editor.setCursorScreenPosition([13, 0])
301299
editor.insertText('\tSayHello("world") ')
302-
suggestions = null
303300
suggestionsPromise = null
304301
advanceClock(completionDelay)
305302

@@ -317,10 +314,10 @@ describe('gocodeprovider', () => {
317314
})
318315

319316
runs(async () => {
320-
suggestions = await suggestionsPromise
321-
322317
expect(provider.getSuggestions).toHaveBeenCalled()
323318
expect(provider.getSuggestions.calls.length).toBe(1)
319+
320+
const suggestions = await suggestionsPromise
324321
expect(suggestions).toBeTruthy()
325322
expect(suggestions.length).toBeGreaterThan(0)
326323
expect(suggestions[0]).toBeTruthy()
@@ -336,7 +333,6 @@ describe('gocodeprovider', () => {
336333
runs(() => {
337334
editor.setCursorScreenPosition([13, 0])
338335
editor.insertText('\tSayHello("world") ')
339-
suggestions = null
340336
suggestionsPromise = null
341337
advanceClock(completionDelay)
342338

@@ -354,10 +350,10 @@ describe('gocodeprovider', () => {
354350
})
355351

356352
runs(async () => {
357-
suggestions = await suggestionsPromise
358-
359353
expect(provider.getSuggestions).toHaveBeenCalled()
360354
expect(provider.getSuggestions.calls.length).toBe(1)
355+
356+
const suggestions = await suggestionsPromise
361357
expect(suggestions).toBeTruthy()
362358
expect(suggestions.length).toBeGreaterThan(0)
363359
expect(suggestions[0]).toBeTruthy()
@@ -375,7 +371,6 @@ describe('gocodeprovider', () => {
375371
runs(() => {
376372
editor.setCursorScreenPosition([13, 0])
377373
editor.insertText('\tSayHello("world")\t')
378-
suggestions = null
379374
suggestionsPromise = null
380375
advanceClock(completionDelay)
381376

@@ -394,7 +389,7 @@ describe('gocodeprovider', () => {
394389
})
395390

396391
runs(async () => {
397-
suggestions = await suggestionsPromise
392+
const suggestions = await suggestionsPromise
398393

399394
expect(provider.getSuggestions).toHaveBeenCalled()
400395
expect(provider.getSuggestions.calls.length).toBe(1)

spec/test/gocover-parser-spec.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ describe('gocover-parser', () => {
8181
expect(r).toBeTruthy()
8282
expect(r.length).toBeGreaterThan(0)
8383
const result = r.filter(item => filePath.endsWith(item.file))
84-
console.log('ranges', r) // eslint-disable-line no-console
85-
console.log('filtered for ' + filePath, result) // eslint-disable-line no-console
8684
expect(result).toBeTruthy()
8785
expect(result.length).toBe(2)
8886
expect(result[0]).toBeDefined()

spec/utils-spec.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,19 @@ describe('utils', () => {
4040
})
4141

4242
describe('stat', () => {
43-
it('is rejected for nonexistent files', async () => {
44-
const fn = async () => {
45-
result = await stat('nonexistentthing')
46-
}
47-
let result = await fn()
48-
expect(result).toBeFalsy()
49-
expect(fn).toThrow()
43+
it('is rejected for nonexistent files', () => {
44+
let result, err
45+
46+
waitsForPromise(() => {
47+
return stat('nonexistentthing')
48+
.then(r => (result = r))
49+
.catch(e => (err = e))
50+
})
51+
52+
runs(() => {
53+
expect(result).toBeFalsy()
54+
expect(err).toBeTruthy()
55+
})
5056
})
5157
})
5258
})

0 commit comments

Comments
 (0)