Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lua/elixir/projectionist/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,20 @@ local config = {
"end",
},
},
["lib/**/live/*_live.ex"] = {
["lib/**/live/*.ex"] = {
type = "liveview",
alternate = "test/{dirname}/live/{basename}_live_test.exs",
alternate = "test/{dirname}/live/{basename}_test.exs",
template = {
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}Live do",
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize} do",
" use {dirname|camelcase|capitalize}, :live_view",
"end",
},
},
["test/**/live/*_live_test.exs"] = {
["test/**/live/*_test.exs"] = {
type = "test",
alternate = "lib/{dirname}/live/{basename}_live.ex",
alternate = "lib/{dirname}/live/{basename}.ex",
template = {
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}LiveTest do",
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}Test do",
" use {dirname|camelcase|capitalize}.ConnCase",
"",
" import Phoenix.LiveViewTest",
Expand Down
30 changes: 22 additions & 8 deletions tests/projectionist_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,28 @@ describe("projectionist", function()
)
end)

it("Eliveview", function()
vim.cmd.Eliveview("project_a_web/user")
vim.cmd.write()

assert.are.same(
vim.fn.readfile("lib/project_a_web/live/user_live.ex"),
{ "defmodule ProjectAWeb.UserLive do", " use ProjectAWeb, :live_view", "end" }
)
describe("Eliveview", function()
it("root path", function()
vim.cmd.Eliveview("project_a_web/user_live")
vim.cmd.write()

assert.are.same(
vim.fn.readfile("lib/project_a_web/live/user_live.ex"),
{ "defmodule ProjectAWeb.UserLive do", " use ProjectAWeb, :live_view", "end" }
)
end)

-- TODO: i think we need a more specific projection transformer here to convert
-- `project_a_web/user_live_index` into the correct module name.
pending("with action", function()
vim.cmd.Eliveview("project_a_web/user_live/index")
vim.cmd.write()

assert.are.same(
vim.fn.readfile("lib/project_a_web/live/user_live/index.ex"),
{ "defmodule ProjectAWeb.UserLive.Index do", " use ProjectAWeb, :live_view", "end" }
)
end)
end)

it("Elivecomponent", function()
Expand Down