From de812d609beb23238781bc9717e14a4047bedd81 Mon Sep 17 00:00:00 2001 From: leafOfTree Date: Mon, 19 Oct 2026 14:20:24 +0000 Subject: [PATCH] Add tests and GitHub Actions Replace the Travis tests, which used a separate repo and no longer ran, with tests in this repo. Each case in test/cases is indented as a whole and should be unchanged, with optional syntax, fold and tag checks. The cases are from the previous tests, plus script-setup.vue for + + diff --git a/test/cases/example.vim b/test/cases/example.vim new file mode 100644 index 0000000..530800c --- /dev/null +++ b/test/cases/example.vim @@ -0,0 +1,15 @@ +" Uses syntax plugins in test/deps +let g:vim_vue_plugin_config = { + \'syntax': { + \ 'template': ['html', 'pug'], + \ 'script': ['javascript', 'typescript', 'coffee'], + \ 'style': ['css', 'scss', 'sass', 'less', 'stylus'], + \ 'docs': 'markdown', + \ 'i18n': ['json', 'yaml'], + \ 'route': 'json', + \}, + \'attribute': 1, + \'keyword': 1, + \'foldexpr': 1, + \'full_syntax': ['scss', 'less'], + \} diff --git a/test/cases/example.vue b/test/cases/example.vue new file mode 100644 index 0000000..fce9e3e --- /dev/null +++ b/test/cases/example.vue @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + +{ + "name": "home", + "meta": { + "requiresAuth": true + } +} + + + +# This is the documentation for component. + + + +en: + hello: "Hello World!" +ja: + hello: "こんにちは、世界!" + + + +{ + "en": { + "language": "Language", + "hello": "hello, world!" + }, + "ja": { + "language": "言語", + "hello": "こんにちは、世界!" + } +} + diff --git a/test/cases/fold.vim b/test/cases/fold.vim new file mode 100644 index 0000000..2ba1f62 --- /dev/null +++ b/test/cases/fold.vim @@ -0,0 +1,15 @@ +let g:vim_vue_plugin_config = { + \'syntax': { + \ 'script': ['javascript'], + \ 'template': ['html'], + \ 'style': ['css'], + \}, + \'foldexpr': 1, + \} + +function! Check() + let levels = [1, 2, 1, 1, 1, 2, 3, 4, 4, 3, 3, 1, 1, 1, 1, 1, 2, 2, 1, 1] + for lnum in range(1, len(levels)) + call ExpectFoldlevel(lnum, levels[lnum - 1]) + endfor +endfunction diff --git a/test/cases/fold.vue b/test/cases/fold.vue new file mode 100644 index 0000000..1f7d4bc --- /dev/null +++ b/test/cases/fold.vue @@ -0,0 +1,20 @@ + + + + + diff --git a/test/cases/indent.vim b/test/cases/indent.vim new file mode 100644 index 0000000..a23b534 --- /dev/null +++ b/test/cases/indent.vim @@ -0,0 +1,9 @@ +let g:vim_vue_plugin_config = { + \'syntax': { + \ 'template': ['html'], + \ 'script': ['javascript'], + \ 'style': ['css', 'sass', 'scss'], + \ 'codepen-additional': ['javascript', 'json'], + \}, + \'initial_indent': ['script', 'style', 'codepen-additional'], + \} diff --git a/test/cases/indent.vue b/test/cases/indent.vue new file mode 100644 index 0000000..52a4b8e --- /dev/null +++ b/test/cases/indent.vue @@ -0,0 +1,27 @@ + + + + + + + + const easings = { + linear: '', + easeInQuad: '', + } + diff --git a/test/cases/keyword.vim b/test/cases/keyword.vim new file mode 100644 index 0000000..1300e7a --- /dev/null +++ b/test/cases/keyword.vim @@ -0,0 +1,16 @@ +let g:vim_vue_plugin_config = { + \'syntax': { + \ 'template': ['html'], + \ 'script': ['javascript', 'typescript'], + \}, + \'keyword': 1, + \'initial_indent': ['script', 'style', 'codepen-additional'], + \} + +function! Check() + call ExpectSyntax('name', 'vueObjectKey') + call ExpectSyntax('data', 'vueObjectFuncKey') + call ExpectSyntax('data', 'vueObjectFuncName') + call ExpectSyntax('computed', 'vueObjectKey') + call ExpectSyntax('mounted', 'vueObjectFuncName') +endfunction diff --git a/test/cases/keyword.vue b/test/cases/keyword.vue new file mode 100644 index 0000000..992725b --- /dev/null +++ b/test/cases/keyword.vue @@ -0,0 +1,45 @@ + + + diff --git a/test/cases/oneline.vim b/test/cases/oneline.vim new file mode 100644 index 0000000..7ac3f54 --- /dev/null +++ b/test/cases/oneline.vim @@ -0,0 +1,22 @@ +" One-line blocks like + +function! Check() + call ExpectSyntax('script', 'javascriptScriptBlock') + call ExpectSyntax('p {', 'cssStyleBlock') + call ExpectSyntax('color', 'cssTextProp') + call ExpectSyntax('p {', 'cssStyleBlock') + call ExpectSyntax('color', 'cssTextProp') + call ExpectSyntax('Hello', 'htmlTemplateBlock') + call CheckSync() +endfunction + +" Syntax from a sync point, as after jumping to a line not displayed yet +function! CheckSync() + silent edit! + call cursor(line('$'), 1) + call search('Hello', 'cW') + if index(SyntaxList(), 'htmlTemplateBlock') == -1 + call Fail('after syncing, Hello should be htmlTemplateBlock, but got ' + \.string(SyntaxList())) + endif +endfunction diff --git a/test/cases/oneline.vue b/test/cases/oneline.vue new file mode 100644 index 0000000..d8db5f4 --- /dev/null +++ b/test/cases/oneline.vue @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/test/cases/random.vim b/test/cases/random.vim new file mode 100644 index 0000000..3df54f4 --- /dev/null +++ b/test/cases/random.vim @@ -0,0 +1,10 @@ +let g:vim_vue_plugin_config = { + \'syntax': { + \ 'template': ['html'], + \ 'script': ['javascript'], + \ 'style': [], + \}, + \'attribute': 1, + \'keyword': 1, + \'foldexpr': 1, + \} diff --git a/test/cases/random.vue b/test/cases/random.vue new file mode 100644 index 0000000..45b12b2 --- /dev/null +++ b/test/cases/random.vue @@ -0,0 +1,151 @@ + + + + diff --git a/test/cases/script-setup.vim b/test/cases/script-setup.vim new file mode 100644 index 0000000..cb8c7d9 --- /dev/null +++ b/test/cases/script-setup.vim @@ -0,0 +1,18 @@ +let g:vim_vue_plugin_config = { + \'syntax': { + \ 'template': ['html'], + \ 'script': ['javascript', 'typescript'], + \}, + \'keyword': 1, + \} + +function! Check() + call ExpectSyntax('withDefaults', 'vue3Keyword') + call ExpectSyntax('defineProps<', 'vue3Keyword') + call ExpectSyntax('defineEmits<', 'vue3Keyword') + call ExpectSyntax('defineModel<', 'vue3Keyword') + call ExpectSyntax('useTemplateRef', 'vue3Keyword') + call ExpectSyntax('ref', 'vue3Keyword') + call ExpectNoSyntax('value < 3', 'vue3Keyword') + call ExpectSyntax('defineExpose', 'vue3Keyword') +endfunction diff --git a/test/cases/script-setup.vue b/test/cases/script-setup.vue new file mode 100644 index 0000000..d64cd51 --- /dev/null +++ b/test/cases/script-setup.vue @@ -0,0 +1,15 @@ + + + diff --git a/test/cases/template.vim b/test/cases/template.vim new file mode 100644 index 0000000..bcaceb8 --- /dev/null +++ b/test/cases/template.vim @@ -0,0 +1,18 @@ +" Nested