---@diagnostic disable: duplicate-set-field, need-check-nil, param-type-mismatch, assign-type-mismatch local docs = require 'bugabinga.pivi.docs' describe( 'pivi docs', function() it( 'locates a core help tag in the runtime path', function() local location = docs.locate 'quickfix' assert.is_table( location ) assert.equal( 'quickfix', location.tag ) assert.is_true( location.path:find( 'quickfix.txt', 1, true ) ~= nil ) end ) it( 'reads the documentation of the running neovim', function() local result = docs.read 'quickfix' assert.is_true( result.found ) assert.equal( 'quickfix.txt', result.file ) assert.is_number( result.line ) assert.is_true( #result.text > 0 ) assert.is_true( result.text:find( '*quickfix*', 1, true ) ~= nil ) end ) it( 'resolves a tag that only this version documents', function() local result = docs.read 'vim.diagnostic.set()' assert.is_true( result.found ) assert.is_true( result.text:find( 'diagnostic', 1, true ) ~= nil ) end ) it( 'bounds the returned section', function() local result = docs.read 'quickfix' local lines = vim.split( result.text, '\n', { plain = true, } ) assert.is_true( #lines <= docs.max_lines ) end ) it( 'offers candidates instead of failing on a missing tag', function() local result = docs.read 'quickf' assert.is_false( result.found ) assert.is_true( #result.candidates > 0 ) assert.is_true( vim.list_contains( result.candidates, 'quickfix' ) ) end ) it( 'returns no candidates for nonsense', function() local result = docs.read 'zzz-not-a-help-tag-zzz' assert.is_false( result.found ) assert.same( {}, result.candidates ) end ) end )