Skip to content

Commit 8757d9f

Browse files
zolrathmhanberg
authored andcommitted
feat(projectionist): Ejson and Elivecomponent
1 parent 98ed986 commit 8757d9f

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

lua/elixir/projectionist/init.lua

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,25 @@ local config = {
7575
"end",
7676
},
7777
},
78+
["lib/**/controllers/*_json.ex"] = {
79+
type = "json",
80+
alternate = "test/{dirname}/controllers/{basename}_json_test.exs",
81+
template = {
82+
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}JSON do",
83+
"end",
84+
},
85+
},
86+
["test/**/controllers/*_json_test.exs"] = {
87+
type = "test",
88+
alternate = "lib/{dirname}/controllers/{basename}_json.ex",
89+
template = {
90+
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}JSONTest do",
91+
" use {dirname|camelcase|capitalize}.ConnCase, async: true",
92+
"",
93+
" alias {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}JSON",
94+
"end",
95+
},
96+
},
7897
["lib/**/components/*.ex"] = {
7998
type = "component",
8099
alternate = "test/{dirname}/components/{basename}_test.exs",
@@ -95,6 +114,26 @@ local config = {
95114
"end",
96115
},
97116
},
117+
["lib/**/live/*_component.ex"] = {
118+
type = "livecomponent",
119+
alternate = "test/{dirname}/live/{basename}_component_test.exs",
120+
template = {
121+
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}Component do",
122+
" use {dirname|camelcase|capitalize}, :live_component",
123+
"end",
124+
},
125+
},
126+
["test/**/live/*_component_test.exs"] = {
127+
type = "test",
128+
alternate = "lib/{dirname}/live/{basename}_component.ex",
129+
template = {
130+
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}ComponentTest do",
131+
" use {dirname|camelcase|capitalize}.ConnCase",
132+
"",
133+
" import Phoenix.LiveViewTest",
134+
"end",
135+
},
136+
},
98137
["lib/**/live/*_live.ex"] = {
99138
type = "liveview",
100139
alternate = "test/{dirname}/live/{basename}_live_test.exs",

tests/projectionist_spec.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ describe("projectionist", function()
4646
})
4747
end)
4848

49+
it("Ejson", function()
50+
vim.cmd.Ejson("project_a_web/user")
51+
vim.cmd.write()
52+
53+
assert.are.same(
54+
vim.fn.readfile("lib/project_a_web/controllers/user_json.ex"),
55+
{ "defmodule ProjectAWeb.UserJSON do", "end" }
56+
)
57+
end)
58+
4959
it("Ecomponent", function()
5060
vim.cmd.Ecomponent("project_a_web/user")
5161
vim.cmd.write()
@@ -66,6 +76,16 @@ describe("projectionist", function()
6676
)
6777
end)
6878

79+
it("Elivecomponent", function()
80+
vim.cmd.Elivecomponent("project_a_web/user")
81+
vim.cmd.write()
82+
83+
assert.are.same(
84+
vim.fn.readfile("lib/project_a_web/live/user_component.ex"),
85+
{ "defmodule ProjectAWeb.UserComponent do", " use ProjectAWeb, :live_component", "end" }
86+
)
87+
end)
88+
6989
it("Etask", function()
7090
vim.cmd.Etask("foo.bar")
7191
vim.cmd.write()

0 commit comments

Comments
 (0)