aboutsummaryrefslogtreecommitdiffstats
path: root/tests/indent
diff options
context:
space:
mode:
authorDennis van den Berg <dennis.vandenberg@nedap.com>2024-07-16 20:29:19 +0200
committer再生花 <hoangtun0810@gmail.com>2024-07-17 09:52:47 +0900
commit0d5e1214a5c386a168dc8e19d7da0ceb0e0bd6f2 (patch)
tree46abee32bdce36d91c690cf00ae39c02f2214720 /tests/indent
parentfeat!: update angular parser to new major (diff)
downloadnvim-treesitter-0d5e1214a5c386a168dc8e19d7da0ceb0e0bd6f2.tar
nvim-treesitter-0d5e1214a5c386a168dc8e19d7da0ceb0e0bd6f2.tar.gz
nvim-treesitter-0d5e1214a5c386a168dc8e19d7da0ceb0e0bd6f2.tar.bz2
nvim-treesitter-0d5e1214a5c386a168dc8e19d7da0ceb0e0bd6f2.tar.lz
nvim-treesitter-0d5e1214a5c386a168dc8e19d7da0ceb0e0bd6f2.tar.xz
nvim-treesitter-0d5e1214a5c386a168dc8e19d7da0ceb0e0bd6f2.tar.zst
nvim-treesitter-0d5e1214a5c386a168dc8e19d7da0ceb0e0bd6f2.zip
feat: add indentation queries for angular
Diffstat (limited to 'tests/indent')
-rw-r--r--tests/indent/angular/defer.html9
-rw-r--r--tests/indent/angular/for.html5
-rw-r--r--tests/indent/angular/if-else.html15
-rw-r--r--tests/indent/angular/switch-case.html13
-rw-r--r--tests/indent/angular_spec.lua70
5 files changed, 112 insertions, 0 deletions
diff --git a/tests/indent/angular/defer.html b/tests/indent/angular/defer.html
new file mode 100644
index 000000000..a85313986
--- /dev/null
+++ b/tests/indent/angular/defer.html
@@ -0,0 +1,9 @@
+@defer (on viewport) {
+ <calendar-cmp />
+} @placeholder (minimum 100ms) {
+ <small-component />
+} @loading (after 100s; minimum 200ms){
+ <loading-spinner />
+} @error {
+ <error-message />
+}
diff --git a/tests/indent/angular/for.html b/tests/indent/angular/for.html
new file mode 100644
index 000000000..591472e23
--- /dev/null
+++ b/tests/indent/angular/for.html
@@ -0,0 +1,5 @@
+@for (item of items; track item.id) {
+ <li>{{ item.name }}</li>
+} @empty {
+ <p>No items</p>
+}
diff --git a/tests/indent/angular/if-else.html b/tests/indent/angular/if-else.html
new file mode 100644
index 000000000..7854e1bc8
--- /dev/null
+++ b/tests/indent/angular/if-else.html
@@ -0,0 +1,15 @@
+@if (someCondition) {
+ <p>someCondition is true</p>
+} @else {
+ <p>someCondition is false</p>
+}
+
+<div>
+ @if (someOther) {
+ <span>True</span>
+
+ @if (nestedCondition) {
+ <span>Nested</span>
+ }
+ }
+</div>
diff --git a/tests/indent/angular/switch-case.html b/tests/indent/angular/switch-case.html
new file mode 100644
index 000000000..17df96609
--- /dev/null
+++ b/tests/indent/angular/switch-case.html
@@ -0,0 +1,13 @@
+<div>
+ @switch (obj.property) {
+ @case (1) {
+ <p>Case 1</p>
+ }
+ @case (2) {
+ <p>Case 2</p>
+ }
+ @default {
+ <p>Default</p>
+ }
+ }
+</div>
diff --git a/tests/indent/angular_spec.lua b/tests/indent/angular_spec.lua
new file mode 100644
index 000000000..2090420ce
--- /dev/null
+++ b/tests/indent/angular_spec.lua
@@ -0,0 +1,70 @@
+local Runner = require("tests.indent.common").Runner
+local runner = Runner:new(it, "tests/indent/angular", {
+ tabstop = 2,
+ shiftwidth = 2,
+ expandtab = true,
+ filetype = "htmlangular",
+})
+
+describe("indent HTML Angular:", function()
+ describe("whole file:", function()
+ runner:whole_file "."
+ end)
+
+ describe("new line:", function()
+ for _, info in ipairs {
+ { 1, 2 },
+ { 2, 2 },
+ { 3, 2 },
+ { 4, 2 },
+ { 6, 0 },
+ { 7, 2 },
+ { 8, 4 },
+ { 10, 4 },
+ { 11, 6 },
+ { 12, 6 },
+ { 13, 4 },
+ { 14, 2 },
+ } do
+ runner:new_line("if-else.html", { on_line = info[1], text = "//", indent = info[2] })
+ end
+
+ for _, info in ipairs {
+ { 1, 2 },
+ { 2, 4 },
+ { 3, 6 },
+ { 4, 6 },
+ { 6, 6 },
+ { 7, 6 },
+ { 9, 6 },
+ { 10, 6 },
+ { 12, 2 },
+ } do
+ runner:new_line("switch-case.html", { on_line = info[1], text = "//", indent = info[2] })
+ end
+
+ for _, info in ipairs {
+ { 1, 2 },
+ { 2, 2 },
+ { 3, 2 },
+ { 4, 2 },
+ { 5, 0 },
+ } do
+ runner:new_line("for.html", { on_line = info[1], text = "//", indent = info[2] })
+ end
+
+ for _, info in ipairs {
+ { 1, 2 },
+ { 2, 2 },
+ { 3, 2 },
+ { 4, 2 },
+ { 5, 2 },
+ { 6, 2 },
+ { 7, 2 },
+ { 8, 2 },
+ { 9, 0 },
+ } do
+ runner:new_line("defer.html", { on_line = info[1], text = "//", indent = info[2] })
+ end
+ end)
+end)