From 58c79a727e79892deb0ca9e00398ac2a58156e61 Mon Sep 17 00:00:00 2001 From: XeroOl Date: Mon, 29 Jul 2024 19:17:18 -0500 Subject: [PATCH] Add tests for editing flsconfig --- test/settings.fnl | 14 +++++++++++++- test/utils/client.fnl | 9 ++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/test/settings.fnl b/test/settings.fnl index 77475f9..666a68c 100644 --- a/test/settings.fnl +++ b/test/settings.fnl @@ -1,5 +1,6 @@ (local faith (require :faith)) (local {: create-client} (require :test.utils)) +(local fennel (require :fennel)) (fn test-path [] (let [{: client : uri : cursor :locations [location]} @@ -60,7 +61,18 @@ (faith.not= [] bad) (faith.= [] good))) +(fn test-editing-settings [] + (let [{: client : uri} (create-client {:main.fnl "" + :flsproject.fnl "{}"}) + uri (uri:gsub "main" "flsproject")] + (client:pretend-this-file-exists! uri "{:extra-globals \"my-new-global\"}") + (client:did-save uri) + (faith.= "my-new-global" client.server.configuration.extra-globals) + (local _ nil)) + nil) + {: test-path : test-extra-globals : test-lints - : test-native-libaries} + : test-native-libaries + : test-editing-settings} diff --git a/test/utils/client.fnl b/test/utils/client.fnl index 2265854..19f1b7a 100644 --- a/test/utils/client.fnl +++ b/test/utils/client.fnl @@ -63,6 +63,12 @@ :textDocument {:uri file} :context {:diagnostics []}}))) +(fn did-save [self file] + (dispatch.handle* self.server + (message.create-notification :textDocument/didSave + {:textDocument {:uri file}}))) + + (local client-mt {:__index {: open-file! : pretend-this-file-exists! @@ -71,7 +77,8 @@ : hover : references : rename - : code-action}}) + : code-action + : did-save}}) {: client-mt : default-encoding