|
4 | 4 | import { lifecycle } from './../spec-helpers' |
5 | 5 | import { ReferencesProvider } from './../../lib/references/references-provider' |
6 | 6 | import path from 'path' |
7 | | -import fs from 'fs' |
| 7 | +import fs from 'fs-extra' |
| 8 | +import { it, beforeEach } from '../async-spec-helpers' // eslint-disable-line |
8 | 9 |
|
9 | 10 | describe('References Provider', () => { |
10 | 11 | let references |
@@ -60,4 +61,41 @@ describe('References Provider', () => { |
60 | 61 | ) |
61 | 62 | }) |
62 | 63 | }) |
| 64 | + |
| 65 | + describe('findReferences', () => { |
| 66 | + let editor |
| 67 | + let gopath = null |
| 68 | + let source = null |
| 69 | + let target = null |
| 70 | + |
| 71 | + beforeEach(async () => { |
| 72 | + gopath = fs.realpathSync(lifecycle.temp.mkdirSync('gopath-')) |
| 73 | + process.env.GOPATH = gopath |
| 74 | + |
| 75 | + await lifecycle.activatePackage() |
| 76 | + const { mainModule } = lifecycle |
| 77 | + references = mainModule.provideReferences() |
| 78 | + |
| 79 | + source = path.join(__dirname, '..', 'fixtures') |
| 80 | + target = path.join(gopath, 'src', 'references') |
| 81 | + fs.copySync(source, target) |
| 82 | + editor = await atom.workspace.open(path.join(target || '.' , 'doc.go')) |
| 83 | + }) |
| 84 | + afterEach(() => { |
| 85 | + lifecycle.teardown() |
| 86 | + }) |
| 87 | + |
| 88 | + it('times out according to the configured Guru timeout', async () => { |
| 89 | + const testTimeout = 1 |
| 90 | + atom.config.set('go-plus.guru.timeout', testTimeout) |
| 91 | + editor.setCursorBufferPosition([22, 2]) |
| 92 | + const refs = await references.findReferences( |
| 93 | + editor, |
| 94 | + editor.getCursorBufferPosition() |
| 95 | + ) |
| 96 | + expect(typeof refs).toBe('object') |
| 97 | + expect(refs.type).toBe('error') |
| 98 | + expect(refs.message.endsWith(testTimeout + 'ms')).toBe(true) |
| 99 | + }) |
| 100 | + }) |
63 | 101 | }) |
0 commit comments