Created
June 13, 2015 17:39
-
-
Save biscuitvile/3f5303356ca2fc30177e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Hat tip to vicramon/vim-qunit and jgdavey/vim-turbux | |
function! OpenQUnit(params) | |
let url = "http://localhost:7357/tests/index.html?filter=" . tolower(a:params) | |
let url = shellescape(url, 1) | |
silent! exec "silent! !open " . url | redraw! | |
endfunction | |
function! RunQunitFile() | |
let file_name = @% | |
let file_name = substitute(file_name, ".[^\/]*\/", "", "g") | |
let file_name = substitute(file_name, "-test.js", "", "g") | |
call OpenQUnit(file_name) | |
endfunction | |
function! RunQunitFocused() | |
let line_number = search('^\s*test\s*(\([''"]\).*)', 'bcnW') | |
let line_text = getline(line_number) | |
let test_name = substitute(line_text, "^\s*test\s*(['\"]", "", "") | |
let test_name = substitute(test_name, "['\"].*$", "", "") | |
call OpenQUnit(test_name) | |
endfunction | |
command! -nargs=* -range RunQunitFile :call RunQunitFile() | |
command! -nargs=* -range RunQunitFocused :call RunQunitFocused() | |
nnoremap <leader>e :RunQunitFile<CR> | |
nnoremap <leader>E :RunQunitFocused<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment