summaryrefslogtreecommitdiff
path: root/test/tclient/tests
diff options
context:
space:
mode:
Diffstat (limited to 'test/tclient/tests')
-rw-r--r--test/tclient/tests/files-associations.lua48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/tclient/tests/files-associations.lua b/test/tclient/tests/files-associations.lua
new file mode 100644
index 00000000..f8f862a9
--- /dev/null
+++ b/test/tclient/tests/files-associations.lua
@@ -0,0 +1,48 @@
+local lclient = require 'tclient.lclient'
+local ws = require 'workspace'
+local files = require 'files'
+local furi = require 'file-uri'
+local util = require 'utility'
+local fs = require 'bee.filesystem'
+
+local rootPath = LOGPATH .. '/files-associations'
+local rootUri = furi.encode(rootPath)
+
+fs.create_directories(fs.path(rootPath))
+
+local filePath = rootPath .. '/test.lua.txt'
+local fileUri = furi.encode(filePath)
+util.saveFile(filePath, '')
+
+---@async
+lclient():start(function (client)
+ client:registerFakers()
+
+ client:register('workspace/configuration', function ()
+ return {
+ {},
+ {
+ ["*.lua.txt"] = "lua",
+ }
+ }
+ end)
+
+ client:initialize {
+ rootPath = rootPath,
+ rootUri = rootUri,
+ workspaceFolders = {
+ {
+ name = 'ws',
+ uri = rootUri,
+ },
+ }
+ }
+
+ ws.awaitReady(rootUri)
+
+ assert(files.isLua(furi.encode 'aaa.lua.txt') == true)
+ assert(files.isLua(furi.encode '/aaa.lua.txt') == true)
+ assert(files.isLua(furi.encode 'D:\\aaa.lua.txt') == true)
+ assert(files.isLua(fileUri) == true)
+ assert(files.exists(fileUri) == true)
+end)