-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodeSuggestion.test.ts
More file actions
89 lines (78 loc) · 3.01 KB
/
Copy pathnodeSuggestion.test.ts
File metadata and controls
89 lines (78 loc) · 3.01 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import {describe, expect, it} from "vitest";
import {getNodeSuggestions} from "../src/suggestion/getNodeSuggestions";
import {DATA_TYPES, FUNCTION_SIGNATURES} from "./data";
describe("getNodeSuggestions", () => {
it("should suggest functions with compatible return types and prioritize exact matches", () => {
// We are looking for suggestions for a 'number' type
const suggestions = getNodeSuggestions("TEXT", FUNCTION_SIGNATURES, DATA_TYPES);
const map = suggestions.map(s => s.functionDefinition?.identifier)
expect(map).toEqual(expect.arrayContaining([
'std::list::first',
'std::list::at',
'std::list::last',
'std::list::pop',
'std::list::find_last',
'std::list::join',
'std::list::find',
'std::number::as_text',
'std::object::get',
'std::boolean::as_text',
'std::text::decode',
'std::text::trim',
'std::text::reverse',
'std::text::replace_last',
'std::text::lowercase',
'std::text::encode',
'std::text::remove',
'std::text::swapcase',
'std::text::append',
'std::text::insert',
'std::text::prepend',
'std::text::hex',
'std::text::replace',
'std::text::from_ascii',
'std::text::octal',
'std::text::capitalize',
'std::text::replace_first',
'std::text::uppercase',
'std::text::at',
'std::control::return',
'std::control::value'
]))
expect(map).toEqual(expect.not.arrayContaining([
"std::number::add"
]))
});
it("should suggest functions with compatible return types and prioritize exact matches for boolean", () => {
// We are looking for suggestions for a 'number' type
const suggestions = getNodeSuggestions("BOOLEAN", FUNCTION_SIGNATURES, DATA_TYPES);
const map = suggestions.map(s => s.functionDefinition?.identifier)
expect(map).toEqual(expect.arrayContaining([
'std::list::first',
'std::list::at',
'std::list::last',
'std::list::pop',
'std::list::find_last',
'std::list::is_empty',
'std::list::find',
'std::number::is_zero',
'std::number::has_digits',
'std::number::is_greater',
'std::number::is_equal',
'std::number::is_positive',
'std::number::is_less',
'std::object::contains_key',
'std::object::get',
'std::boolean::from_number',
'std::boolean::is_equal',
'std::boolean::from_text',
'std::boolean::negate',
'std::text::is_equal',
'std::text::ends_with',
'std::text::start_with',
'std::text::contains',
'std::control::return',
'std::control::value'
]))
});
});