Skip to content

Commit

Permalink
feat(javascript): more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Goose97 committed Nov 21, 2024
1 parent ddda55f commit 6f44821
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
34 changes: 25 additions & 9 deletions tests/neolog/actions/lang/javascript_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,38 @@ describe("javascript", function()
it("supports variable declaration", function()
local actions = require("neolog.actions")

local input = [[
const fo|o = "bar"
]]
helper.assert_scenario({
input = [[
const fo|o = "bar"
]],
filetype = "javascript",
action = function()
actions.add_log({ log_template = [[console.log("%identifier", %identifier)]], position = "below" })
end,
expected = [[
const foo = "bar"
console.log("foo", foo)
]],
})
end)

local expected = [[
const foo = "bar"
console.log("foo", foo)
]]
it("supports variable assignment", function()
local actions = require("neolog.actions")

helper.assert_scenario({
input = input,
input = [[
const foo = "bar"
fo|o = "baz"
]],
filetype = "javascript",
action = function()
actions.add_log({ log_template = [[console.log("%identifier", %identifier)]], position = "below" })
end,
expected = expected,
expected = [[
const foo = "bar"
foo = "baz"
console.log("foo", foo)
]],
})
end)

Expand Down
20 changes: 20 additions & 0 deletions tests/neolog/actions/lang/typescript_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ describe("typescript", function()
})
end)

it("supports variable assignment", function()
local actions = require("neolog.actions")

helper.assert_scenario({
input = [[
const foo = "bar"
fo|o = "baz"
]],
filetype = "typescript",
action = function()
actions.add_log({ log_template = [[console.log("%identifier", %identifier)]], position = "below" })
end,
expected = [[
const foo = "bar"
foo = "baz"
console.log("foo", foo)
]],
})
end)

it("supports array destructuring assignment", function()
local actions = require("neolog.actions")

Expand Down

0 comments on commit 6f44821

Please sign in to comment.