From bb8d93848050276d87d920569ebee9ec7c8a89c9 Mon Sep 17 00:00:00 2001 From: yaohaosen Date: Thu, 21 Aug 2025 20:58:31 +0800 Subject: [PATCH] [LSP] Add and sync testcases Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICU4SC Signed-off-by: yaohaosen --- .../unit/lsp/refactors_convert_chain_test.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/ets2panda/test/unit/lsp/refactors_convert_chain_test.cpp b/ets2panda/test/unit/lsp/refactors_convert_chain_test.cpp index 3a53f51d66..a5c01ae80a 100644 --- a/ets2panda/test/unit/lsp/refactors_convert_chain_test.cpp +++ b/ets2panda/test/unit/lsp/refactors_convert_chain_test.cpp @@ -112,4 +112,32 @@ let ccc = /*1*/foo.bar ? foo.bar.baz: "whenFalse";/*2*/ ASSERT_EQ(std::string(TO_NAMED_CHAIN_NAME), result[0].action.name); } +TEST_F(LspChainRefTests, ConvertChainRefactor4) +{ + std::vector files = {"ConvertChainRefactor4.ets"}; + std::vector texts = {R"(interface A { baz?: string } +interface Foo{ +bar?: A +} +declare let foo: Foo; +let ccc = /*1*/foo.bar ? foo.bar.baz: "whenFalse";/*2*/ + )"}; + + auto filePaths = CreateTempFile(files, texts); + size_t const expectedFileCount = 1; + ASSERT_EQ(filePaths.size(), expectedFileCount); + + auto pos = texts[0].find("/*1*/"); + ASSERT_NE(pos, std::string::npos); + Initializer initializer = Initializer(); + auto ctx = initializer.CreateContext(filePaths[0].c_str(), ES2PANDA_STATE_CHECKED); + ark::es2panda::lsp::RefactorContext refactorContext; + refactorContext.context = ctx; + refactorContext.kind = std::string(TO_NAMED_CHAIN_KIND); + refactorContext.span.pos = pos + REFACTOR_CHAIN_POSITION_OFFSET; + auto result = GetApplicableRefactorsImpl(&refactorContext); + initializer.DestroyContext(ctx); + ASSERT_EQ(1, result.size()); +} + } // namespace \ No newline at end of file -- Gitee