mirror of
https://github.com/posva/vim-vue.git
synced 2025-12-10 11:21:52 +08:00
Add initial tests
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/pack
|
||||||
25
test/install.sh
Executable file
25
test/install.sh
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
repos=(
|
||||||
|
'junegunn/vader.vim'
|
||||||
|
'cakebaker/scss-syntax.vim'
|
||||||
|
'digitaltoad/vim-pug'
|
||||||
|
'groenewege/vim-less'
|
||||||
|
'kchmck/vim-coffee-script'
|
||||||
|
'slm-lang/vim-slm'
|
||||||
|
'wavded/vim-stylus'
|
||||||
|
)
|
||||||
|
|
||||||
|
cd "$(dirname "$0")/.."
|
||||||
|
mkdir -p pack/testing/start
|
||||||
|
cd pack/testing/start
|
||||||
|
|
||||||
|
# Add our plugin to the pack.
|
||||||
|
ln -s ../../.. vim-vue
|
||||||
|
|
||||||
|
for repo in ${repos[@]}
|
||||||
|
do
|
||||||
|
git clone https://github.com/$repo.git
|
||||||
|
done
|
||||||
32
test/readme.md
Normal file
32
test/readme.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Vader Tests
|
||||||
|
|
||||||
|
> Requires Vim 8 or Neovim, due to the way dependencies are installed.
|
||||||
|
|
||||||
|
To run the tests, you need to install the dependencies first. Use the
|
||||||
|
[installation script](install.sh):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
test/install.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running the tests from the command line
|
||||||
|
|
||||||
|
You can run the tests with the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
vim -u test/vimrc -c 'Vader! test/*.vader'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running the tests from within Vim
|
||||||
|
|
||||||
|
Open vim with:
|
||||||
|
|
||||||
|
```
|
||||||
|
vim -u test/vimrc
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, you can run the tests with the following command:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
:Vader test/*.vader
|
||||||
|
```
|
||||||
68
test/test_indent.vader
Normal file
68
test/test_indent.vader
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
#
|
||||||
|
# HTML
|
||||||
|
#
|
||||||
|
Given vue(An unindented html template):
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
Hello
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
Do:
|
||||||
|
gg=G
|
||||||
|
|
||||||
|
Expect (The html template got indented):
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
Hello
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
#
|
||||||
|
# JavaScript
|
||||||
|
#
|
||||||
|
Given vue(An unindented JavaScript region):
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
methods: {
|
||||||
|
foo() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
Do (Indent the whole buffer):
|
||||||
|
gg=G
|
||||||
|
|
||||||
|
Expect vue(TODO):
|
||||||
|
* TODO: fix the indent script to exclude the surrounding html tag
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
methods: {
|
||||||
|
foo() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
#
|
||||||
|
# CSS
|
||||||
|
#
|
||||||
|
Given vue(An unindented css region):
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background: tomato;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
Do:
|
||||||
|
gg=G
|
||||||
|
|
||||||
|
Expect vue(The css region got indented):
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background: tomato;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
34
test/test_syntax.vader
Normal file
34
test/test_syntax.vader
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#
|
||||||
|
# HTML
|
||||||
|
#
|
||||||
|
Given vue(HTML template without lang attribute):
|
||||||
|
<template>
|
||||||
|
<div></div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'htmlTag', SyntaxAt(2, 3)
|
||||||
|
|
||||||
|
#
|
||||||
|
# JavaScript
|
||||||
|
#
|
||||||
|
Given vue:
|
||||||
|
<script>
|
||||||
|
//
|
||||||
|
</script>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'javaScriptLineComment', SyntaxAt(2, 3)
|
||||||
|
" TODO: Assert that the script tag is highlighted as HTML
|
||||||
|
|
||||||
|
#
|
||||||
|
# CSS
|
||||||
|
#
|
||||||
|
Given vue(CSS region without lang attribute):
|
||||||
|
<style>
|
||||||
|
/**/
|
||||||
|
</style>
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
AssertEqual 'cssComment', SyntaxAt(2, 3)
|
||||||
|
" TODO Assert that the style tag is highlighted as HTML
|
||||||
13
test/vimrc
Normal file
13
test/vimrc
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
set nocompatible
|
||||||
|
|
||||||
|
let &packpath = expand('<sfile>:p:h:h')
|
||||||
|
|
||||||
|
" Remove first and last entry from runtimepath, to prevent loading plugins from ~/.vim
|
||||||
|
let &runtimepath = substitute(&runtimepath, '\v^.{-},(.*),.*$', '\1', '')
|
||||||
|
|
||||||
|
filetype plugin indent on
|
||||||
|
syntax on
|
||||||
|
|
||||||
|
set expandtab
|
||||||
|
set shiftwidth=2
|
||||||
|
set softtabstop=2
|
||||||
Reference in New Issue
Block a user