spacevim/bundle/nerdtree-git-plugin/tests/test_all.vim
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

110 lines
5.0 KiB
VimL

let s:suite = themis#suite('Test for nerdtree-git-plugin')
let s:assert = themis#helper('assert')
call themis#helper('command').with(s:)
function! s:suite.Initializing() abort
NERDTreeFocus
call s:assert.exists('g:NERDTree')
call s:assert.exists('g:loaded_nerdtree_git_status')
call g:NERDTree.CursorToTreeWin()
call s:assert.exists('b:NERDTree')
endfunction
function! s:suite.BuildGitWorkdirCommand() abort
let l:cmd = gitstatus#util#BuildGitWorkdirCommand('/workdir', {})
call s:assert.equal(l:cmd, ['git', '-C', '/workdir', 'rev-parse', '--show-toplevel'])
let l:cmd = gitstatus#util#BuildGitWorkdirCommand('/workdir', {'NERDTreeGitStatusGitBinPath': '/path/to/git'})
call s:assert.equal(l:cmd, ['/path/to/git', '-C', '/workdir', 'rev-parse', '--show-toplevel'])
endfunction
function! s:suite.BuildGitStatusCommand() abort
let l:cmd = gitstatus#util#BuildGitStatusCommand('/workdir', {})
call s:assert.equal(l:cmd, ['git', '-C', '/workdir', 'status', '--porcelain=v2', '-z'])
let l:cmd = gitstatus#util#BuildGitStatusCommand('/workdir', {
\ 'NERDTreeGitStatusPorcelainVersion': 1
\ })
call s:assert.equal(l:cmd, ['git', '-C', '/workdir', 'status', '--porcelain', '-z'])
let l:cmd = gitstatus#util#BuildGitStatusCommand('/workdir', {
\ 'NERDTreeGitStatusUntrackedFilesMode': 'all'
\ })
call s:assert.equal(l:cmd, ['git', '-C', '/workdir', 'status', '--porcelain=v2', '-z', '--untracked-files=all'])
let l:cmd = gitstatus#util#BuildGitStatusCommand('/workdir', {
\ 'NERDTreeGitStatusShowIgnored': 1
\ })
call s:assert.equal(l:cmd, ['git', '-C', '/workdir', 'status', '--porcelain=v2', '-z', '--ignored=traditional'])
let l:cmd = gitstatus#util#BuildGitStatusCommand('/workdir', {
\ 'NERDTreeGitStatusShowIgnored': 0
\ })
call s:assert.equal(l:cmd, ['git', '-C', '/workdir', 'status', '--porcelain=v2', '-z'])
let l:cmd = gitstatus#util#BuildGitStatusCommand('/workdir', {
\ 'NERDTreeGitStatusIgnoreSubmodules': 'dirty'
\ })
call s:assert.equal(l:cmd, ['git', '-C', '/workdir', 'status', '--porcelain=v2', '-z', '--ignore-submodules=dirty'])
let l:cmd = gitstatus#util#BuildGitStatusCommand('/workdir', {
\ 'NERDTreeGitStatusPorcelainVersion': 1,
\ 'NERDTreeGitStatusUntrackedFilesMode': 'all',
\ 'NERDTreeGitStatusShowIgnored': 1,
\ 'NERDTreeGitStatusIgnoreSubmodules': 'dirty'
\ })
call s:assert.equal(l:cmd, ['git', '-C', '/workdir', 'status', '--porcelain', '-z',
\ '--untracked-files=all',
\ '--ignored=traditional',
\ '--ignore-submodules=dirty'])
endfunction
function! s:suite.Logger() abort
let l:logger = gitstatus#log#NewLogger(1) " info
let l:messages = execute('messages')
call l:logger.debug('debug')
call s:assert.equal(execute('messages'), l:messages)
call l:logger.error('error')
call s:assert.equal(execute('messages'), l:messages . "\n[nerdtree-git-status] error")
endfunction
function! s:suite.CustomIndicator() abort
let g:NERDTreeGitStatusIndicatorMapCustom = {'Untracked': '~'}
let l:staged = gitstatus#getIndicator('Staged')
call s:assert.equal(gitstatus#getIndicator('Staged'), l:staged)
call s:assert.equal(gitstatus#getIndicator('Untracked'), '~')
" Vim(return):E716: Key not present in Dictionary
Throws /E716/ gitstatus#getIndicator('no such status')
endfunction
function! s:suite.UpdateParentDirsStatus() abort
let l:opts = {'NERDTreeGitStatusDirDirtyOnly': 1}
let l:root = '/root'
let l:cache = {}
let l:pathStr = '/root/dir1/dir2/dir3'
let l:cache[l:pathStr] = 'Untracked'
call gitstatus#util#UpdateParentDirsStatus(l:cache, l:root, l:pathStr, 'Untracked', l:opts)
call s:assert.equal({'/root/dir1': 'Dirty', '/root/dir1/dir2': 'Dirty', '/root/dir1/dir2/dir3': 'Untracked'}, l:cache)
let l:pathStr = '/root/dir1/dir2/file0'
let l:cache[l:pathStr] = 'Staged'
call gitstatus#util#UpdateParentDirsStatus(l:cache, l:root, l:pathStr, 'Staged', l:opts)
call s:assert.equal({'/root/dir1': 'Dirty', '/root/dir1/dir2': 'Dirty', '/root/dir1/dir2/dir3': 'Untracked', '/root/dir1/dir2/file0': 'Staged'}, l:cache)
let l:opts = {'NERDTreeGitStatusDirDirtyOnly': 0}
let l:cache = {}
let l:pathStr = '/root/dir1/dir2/dir3'
let l:cache[l:pathStr] = 'Untracked'
call gitstatus#util#UpdateParentDirsStatus(l:cache, l:root, l:pathStr, 'Untracked', l:opts)
call s:assert.equal({'/root/dir1': 'Untracked', '/root/dir1/dir2': 'Untracked', '/root/dir1/dir2/dir3': 'Untracked'}, l:cache)
let l:cache['/root/dir1/file1'] = 'Staged'
call gitstatus#util#UpdateParentDirsStatus(l:cache, l:root, '/root/dir1/file1', 'Staged', l:opts)
call s:assert.equal({'/root/dir1': 'Dirty','/root/dir1/file1': 'Staged', '/root/dir1/dir2': 'Untracked', '/root/dir1/dir2/dir3': 'Untracked'}, l:cache)
endfunction