1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 06:20:05 +08:00
SpaceVim/bundle/dein.vim/test/base.vim
2022-01-01 22:47:56 +08:00

79 lines
2.1 KiB
VimL

" set verbose=1
let s:suite = themis#suite('base')
let s:assert = themis#helper('assert')
let s:path = tempname()
function! s:suite.before_each() abort
call dein#min#_init()
endfunction
function! s:suite.block_normal() abort
call s:assert.equals(dein#begin(s:path), 0)
call s:assert.equals(dein#end(), 0)
call s:assert.equals(dein#begin(s:path), 0)
call s:assert.equals(dein#end(), 0)
endfunction
function! s:suite.begin_invalid() abort
call s:assert.equals(dein#begin(s:path), 0)
call s:assert.equals(dein#begin(s:path), 1)
call dein#min#_init()
call s:assert.equals(dein#end(), 1)
call s:assert.equals(dein#end(), 1)
call s:assert.equals(dein#begin(getcwd() . '/plugin'), 1)
endfunction
function! s:suite.end_invalid() abort
call s:assert.equals(dein#end(), 1)
endfunction
function! s:suite.add_normal() abort
call s:assert.equals(dein#begin(s:path), 0)
call dein#add('foo', {})
call s:assert.equals(g:dein#_plugins.foo.name, 'foo')
call dein#add('bar')
call s:assert.equals(g:dein#_plugins.bar.name, 'bar')
call s:assert.equals(dein#end(), 0)
endfunction
function! s:suite.add_overwrite() abort
call s:assert.equals(dein#begin(s:path), 0)
call dein#parse#_add('foo', {}, v:true)
call s:assert.equals(g:dein#_plugins.foo.sourced, 0)
call dein#parse#_add('foo', { 'sourced': 1 }, v:true)
call s:assert.equals(g:dein#_plugins.foo.sourced, 1)
call dein#parse#_add('foo', { 'sourced': 2 }, v:false)
call s:assert.equals(g:dein#_plugins.foo.sourced, 1)
call s:assert.equals(dein#end(), 0)
endfunction
function! s:suite.get() abort
let plugins = { 'foo': {'name': 'bar'} }
call dein#begin(s:path)
call dein#add('foo', { 'name': 'bar' })
call s:assert.equals(dein#get('bar').name, 'bar')
call dein#add('foo')
call s:assert.equals(dein#get('foo').name, 'foo')
call dein#end()
endfunction
function! s:suite.expand() abort
call s:assert.equals(dein#util#_expand('~'),
\ dein#util#_substitute_path(fnamemodify('~', ':p')))
call s:assert.equals(dein#util#_expand('$HOME'),
\ dein#util#_substitute_path($HOME))
endfunction