Skip to content

Commit

Permalink
chore(completion): fix failure tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chemzqm committed Oct 21, 2022
1 parent bdd0b26 commit 3a13758
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/__tests__/completion/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ afterEach(async () => {
await helper.reset()
})

async function triggerCompletion(source: string): Promise<void> {
await nvim.call('coc#start', { source })
function triggerCompletion(source: string): void {
nvim.call('coc#start', { source }, true)
}

async function create(items: string[] | VimCompleteItem[], trigger = true): Promise<string> {
Expand All @@ -48,7 +48,7 @@ async function create(items: string[] | VimCompleteItem[], trigger = true): Prom
await nvim.input('i')
}
if (trigger) {
await triggerCompletion(name)
triggerCompletion(name)
await helper.waitPopup()
}
return name
Expand Down Expand Up @@ -119,7 +119,7 @@ describe('completion', () => {
let name = await create(['foo', 'bar', 'foobar'])
await helper.confirmCompletion(1)
await nvim.input('<CR>f')
await triggerCompletion(name)
triggerCompletion(name)
let info = await nvim.call('coc#pum#info')
expect(info.index).toBe(1)
})
Expand Down Expand Up @@ -244,7 +244,7 @@ describe('completion', () => {
}
disposables.push(sources.addSource(source))
await nvim.input('i')
await triggerCompletion('dash')
triggerCompletion('dash')
await helper.waitPopup()
await nvim.input('-')
await helper.waitValue(() => {
Expand Down Expand Up @@ -1179,7 +1179,7 @@ describe('completion', () => {
})
}))
await nvim.input('i')
await triggerCompletion('test')
triggerCompletion('test')
await helper.waitPopup()
let winid = await nvim.call('coc#float#get_float_by_kind', ['pum'])
let win = nvim.createWindow(winid)
Expand Down Expand Up @@ -1307,7 +1307,7 @@ describe('completion', () => {
await nvim.setLine('f')
await nvim.input('A')
await doc.synchronize()
await triggerCompletion('insert')
triggerCompletion('insert')
await helper.waitPopup()
let line = await nvim.line
expect(line).toBe('f')
Expand Down
5 changes: 4 additions & 1 deletion src/__tests__/completion/language.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ describe('language source', () => {
}]
}
disposables.push(languages.registerCompletionItemProvider('foo', 'f', null, provider))
await nvim.input('i')
let mode = await nvim.mode
if (mode.mode !== 'i') {
await nvim.input('i')
}
nvim.call('coc#start', { source: 'foo' }, true)
await helper.waitPopup()
await helper.waitValue(async () => {
Expand Down

0 comments on commit 3a13758

Please sign in to comment.