#[cfg(test)]
mod tests {
use crate::handlers::test_lib::ProviderVirtualWorkspace;
use emmylua_code_analysis::{DiagnosticCode, Emmyrc};
use lsp_types::CodeActionOrCommand;
#[test]
fn test_1() {
let mut ws = ProviderVirtualWorkspace::new();
ws.def(
r#"
---@class Cast1
---@field get fun(self: self, a: number): Cast1?
"#,
);
let actions = ws
.check_code_action(
r#"
---@type Cast1
local A
local _a = A:get(1):get(2):get(3)
"#,
)
.unwrap();
assert_eq!(actions.len(), 8);
}
#[test]
fn test_add_doc_tag() {
let mut ws = ProviderVirtualWorkspace::new();
let mut emmyrc = Emmyrc::default();
emmyrc
.diagnostics
.enables
.push(DiagnosticCode::UnknownDocTag);
ws.analysis.update_config(emmyrc.into());
let actions = ws
.check_code_action(
r#"
---@class Cast1
---@foo bar
"#,
)
.unwrap();
assert_eq!(actions.len(), 4);
let CodeActionOrCommand::CodeAction(action) = &actions[0] else {
panic!()
};
assert_eq!(action.title, "Add @foo to the list of known tags")
}
}