From 6eeb9abb970583d52c9dad5f87e7de49de2a9b94 Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Tue, 16 Jul 2024 22:14:10 +0800 Subject: [PATCH] add select lib test --- nixd/tools/nixd/test/completion-select-lib.md | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 nixd/tools/nixd/test/completion-select-lib.md diff --git a/nixd/tools/nixd/test/completion-select-lib.md b/nixd/tools/nixd/test/completion-select-lib.md new file mode 100644 index 000000000..50172b57a --- /dev/null +++ b/nixd/tools/nixd/test/completion-select-lib.md @@ -0,0 +1,77 @@ +# RUN: nixd --lit-test \ +# RUN: --nixpkgs-expr="{ lib.hello.meta.description = \"Very Nice\"; }" \ +# RUN: < %s | FileCheck %s + + +<-- initialize(0) + +```json +{ + "jsonrpc":"2.0", + "id":0, + "method":"initialize", + "params":{ + "processId":123, + "rootPath":"", + "capabilities":{ + }, + "trace":"off" + } +} +``` + + +<-- textDocument/didOpen + + +```json +{ + "jsonrpc":"2.0", + "method":"textDocument/didOpen", + "params":{ + "textDocument":{ + "uri":"file:///completion.nix", + "languageId":"nix", + "version":1, + "text":"lib.hel" + } + } +} +``` + +```json +{ + "jsonrpc": "2.0", + "id": 1, + "method": "textDocument/completion", + "params": { + "textDocument": { + "uri": "file:///completion.nix" + }, + "position": { + "line": 0, + "character": 6 + }, + "context": { + "triggerKind": 1 + } + } +} +``` + +``` + CHECK: "isIncomplete": false, +CHECK-NEXT: "items": [ +CHECK-NEXT: { +CHECK-NEXT: "data": "{\"Prefix\":\"hel\",\"Scope\":[\"lib\"]}", +CHECK-NEXT: "kind": 5, +CHECK-NEXT: "label": "hello", +CHECK-NEXT: "score": 0 +CHECK-NEXT: } +CHECK-NEXT: ] +``` + + +```json +{"jsonrpc":"2.0","method":"exit"} +```