Skip to content

Commit e504b87

Browse files
authored
fix(projectionist): don't append live to file and module name (#121)
1 parent 7af93b7 commit e504b87

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

lua/elixir/projectionist/init.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,20 @@ local config = {
134134
"end",
135135
},
136136
},
137-
["lib/**/live/*_live.ex"] = {
137+
["lib/**/live/*.ex"] = {
138138
type = "liveview",
139-
alternate = "test/{dirname}/live/{basename}_live_test.exs",
139+
alternate = "test/{dirname}/live/{basename}_test.exs",
140140
template = {
141-
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}Live do",
141+
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize} do",
142142
" use {dirname|camelcase|capitalize}, :live_view",
143143
"end",
144144
},
145145
},
146-
["test/**/live/*_live_test.exs"] = {
146+
["test/**/live/*_test.exs"] = {
147147
type = "test",
148-
alternate = "lib/{dirname}/live/{basename}_live.ex",
148+
alternate = "lib/{dirname}/live/{basename}.ex",
149149
template = {
150-
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}LiveTest do",
150+
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}Test do",
151151
" use {dirname|camelcase|capitalize}.ConnCase",
152152
"",
153153
" import Phoenix.LiveViewTest",

tests/projectionist_spec.lua

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,28 @@ describe("projectionist", function()
6666
)
6767
end)
6868

69-
it("Eliveview", function()
70-
vim.cmd.Eliveview("project_a_web/user")
71-
vim.cmd.write()
72-
73-
assert.are.same(
74-
vim.fn.readfile("lib/project_a_web/live/user_live.ex"),
75-
{ "defmodule ProjectAWeb.UserLive do", " use ProjectAWeb, :live_view", "end" }
76-
)
69+
describe("Eliveview", function()
70+
it("root path", function()
71+
vim.cmd.Eliveview("project_a_web/user_live")
72+
vim.cmd.write()
73+
74+
assert.are.same(
75+
vim.fn.readfile("lib/project_a_web/live/user_live.ex"),
76+
{ "defmodule ProjectAWeb.UserLive do", " use ProjectAWeb, :live_view", "end" }
77+
)
78+
end)
79+
80+
-- TODO: i think we need a more specific projection transformer here to convert
81+
-- `project_a_web/user_live_index` into the correct module name.
82+
pending("with action", function()
83+
vim.cmd.Eliveview("project_a_web/user_live/index")
84+
vim.cmd.write()
85+
86+
assert.are.same(
87+
vim.fn.readfile("lib/project_a_web/live/user_live/index.ex"),
88+
{ "defmodule ProjectAWeb.UserLive.Index do", " use ProjectAWeb, :live_view", "end" }
89+
)
90+
end)
7791
end)
7892

7993
it("Elivecomponent", function()

0 commit comments

Comments
 (0)