forked from CopilotC-Nvim/CopilotChat.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_spec.lua
More file actions
40 lines (35 loc) · 1.27 KB
/
utils_spec.lua
File metadata and controls
40 lines (35 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
local utils = require('CopilotChat.utils')
describe('CopilotChat.utils', function()
it('empty', function()
assert.is_true(utils.empty(nil))
assert.is_true(utils.empty(''))
assert.is_true(utils.empty(' '))
assert.is_true(utils.empty({}))
assert.is_false(utils.empty({ 1 }))
assert.is_false(utils.empty('abc'))
assert.is_false(utils.empty(0))
end)
it('split_lines', function()
assert.are.same(utils.split_lines(''), {})
assert.are.same(utils.split_lines('a\nb'), { 'a', 'b' })
assert.are.same(utils.split_lines('a\r\nb'), { 'a', 'b' })
assert.are.same(utils.split_lines('a\nb\n'), { 'a', 'b', '' })
end)
it('make_string', function()
assert.equals('a b 1', utils.make_string('a', 'b', 1))
assert.equals(vim.inspect({ x = 1 }), utils.make_string({ x = 1 }))
assert.equals('msg', utils.make_string('error:1: msg'))
end)
it('uuid', function()
local uuid1 = utils.uuid()
local uuid2 = utils.uuid()
assert.equals('string', type(uuid1))
assert.not_equals(uuid1, uuid2)
assert.equals(36, #uuid1)
end)
it('to_table', function()
assert.are.same({ 1, 2, 3 }, utils.to_table(1, 2, 3))
assert.are.same({ 1, 2, 3 }, utils.to_table({ 1, 2 }, 3))
assert.are.same({ 1 }, utils.to_table(nil, 1))
end)
end)