From 82067c7d14fafaaa05509195d115ee884eb35cec Mon Sep 17 00:00:00 2001 From: Adriaan Zonnenberg Date: Wed, 22 Mar 2017 23:33:36 +0100 Subject: [PATCH] Add initial tests --- .gitignore | 1 + test/install.sh | 25 ++++++++++++++++ test/readme.md | 32 ++++++++++++++++++++ test/test_indent.vader | 68 ++++++++++++++++++++++++++++++++++++++++++ test/test_syntax.vader | 34 +++++++++++++++++++++ test/vimrc | 13 ++++++++ 6 files changed, 173 insertions(+) create mode 100644 .gitignore create mode 100755 test/install.sh create mode 100644 test/readme.md create mode 100644 test/test_indent.vader create mode 100644 test/test_syntax.vader create mode 100644 test/vimrc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5c0e324 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/pack diff --git a/test/install.sh b/test/install.sh new file mode 100755 index 0000000..ccc8e2a --- /dev/null +++ b/test/install.sh @@ -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 diff --git a/test/readme.md b/test/readme.md new file mode 100644 index 0000000..57d0f0c --- /dev/null +++ b/test/readme.md @@ -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 +``` diff --git a/test/test_indent.vader b/test/test_indent.vader new file mode 100644 index 0000000..2e283b2 --- /dev/null +++ b/test/test_indent.vader @@ -0,0 +1,68 @@ +# +# HTML +# +Given vue(An unindented html template): + + +Do: + gg=G + +Expect (The html template got indented): + + +# +# JavaScript +# +Given vue(An unindented JavaScript region): + + +Do (Indent the whole buffer): + gg=G + +Expect vue(TODO): +* TODO: fix the indent script to exclude the surrounding html tag + + +# +# CSS +# +Given vue(An unindented css region): + + +Do: + gg=G + +Expect vue(The css region got indented): + diff --git a/test/test_syntax.vader b/test/test_syntax.vader new file mode 100644 index 0000000..f44b244 --- /dev/null +++ b/test/test_syntax.vader @@ -0,0 +1,34 @@ +# +# HTML +# +Given vue(HTML template without lang attribute): + + +Execute: + AssertEqual 'htmlTag', SyntaxAt(2, 3) + +# +# JavaScript +# +Given vue: + + +Execute: + AssertEqual 'javaScriptLineComment', SyntaxAt(2, 3) + " TODO: Assert that the script tag is highlighted as HTML + +# +# CSS +# +Given vue(CSS region without lang attribute): + + +Execute: + AssertEqual 'cssComment', SyntaxAt(2, 3) + " TODO Assert that the style tag is highlighted as HTML diff --git a/test/vimrc b/test/vimrc new file mode 100644 index 0000000..c0b165d --- /dev/null +++ b/test/vimrc @@ -0,0 +1,13 @@ +set nocompatible + +let &packpath = expand(':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