You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test('identifies and extracts placeholders from JSON-like string',()=>{
5
-
// Sample JSON-like string with placeholders
3
+
test('identifies and extracts placeholders from JSON-like string',()=>{
4
+
// Sample JSON-like string with placeholders
6
5
7
-
constinputString=`stack (
8
-
"ok this is an example",
9
-
{
10
-
"input": {
11
-
"dictionary": {
12
-
"Use the chatCompletion endpoint from openai to return a response": "callOpenAI",
13
-
"Find a good name for this method.": "pickMethodName"
14
-
},
15
-
"textCode": isolatedFunction
6
+
constinputString=`stack (
7
+
"ok this is an example",
8
+
{
9
+
"input": {
10
+
"dictionary": {
11
+
"Use the chatCompletion endpoint from openai to return a response": "callOpenAI",
12
+
"Find a good name for this method.": "pickMethodName"
16
13
},
17
-
"outExample": {
18
-
"methodName": "callOpenAI"
19
-
}
20
-
})`;
14
+
"textCode": isolatedFunction
15
+
},
16
+
"outExample": {
17
+
"methodName": "callOpenAI"
18
+
}
19
+
})`;
21
20
22
-
constresult=transformJSON(inputString);
21
+
constresult=transformJSON(inputString);
23
22
24
-
constexpectedOutput={
25
-
input:
26
-
'{"dictionary":{"Use the chatCompletion endpoint from openai to return a response":"callOpenAI","Find a good name for this method.":"pickMethodName"},"textCode":isolatedFunction}',
27
-
outExample: {
28
-
methodName: 'callOpenAI',
29
-
},
30
-
};
23
+
constexpectedOutput={
24
+
input:
25
+
'{"dictionary":{"Use the chatCompletion endpoint from openai to return a response":"callOpenAI","Find a good name for this method.":"pickMethodName"},"textCode":isolatedFunction}',
26
+
outExample: {
27
+
methodName: 'callOpenAI',
28
+
},
29
+
};
31
30
32
-
// Check if the result matches the expected output
33
-
expect(result).toEqual(expectedOutput);
34
-
});
31
+
// Check if the result matches the expected output
32
+
expect(result).toEqual(expectedOutput);
33
+
});
35
34
36
-
test('extract',()=>{
37
-
// Sample JSON-like string with placeholders
35
+
test('extract',()=>{
36
+
// Sample JSON-like string with placeholders
38
37
39
-
constinputString=`stack("test", {
40
-
input: { test: "ok" },
41
-
outExample: { test: "ok" }
42
-
})`;
38
+
constinputString=`stack("test", {
39
+
input: { test: "ok" },
40
+
outExample: { test: "ok" }
41
+
})`;
43
42
44
-
constresult=transformJSON(inputString);
43
+
constresult=transformJSON(inputString);
45
44
46
-
constexpectedOutput={
47
-
input: `{"test":"ok"}`,
48
-
outExample: {test: 'ok'},
49
-
};
45
+
constexpectedOutput={
46
+
input: `{"test":"ok"}`,
47
+
outExample: {test: 'ok'},
48
+
};
50
49
51
-
// Check if the result matches the expected output
52
-
expect(result).toEqual(expectedOutput);
53
-
});
50
+
// Check if the result matches the expected output
51
+
expect(result).toEqual(expectedOutput);
52
+
});
54
53
55
-
test('single quotes',()=>{
56
-
// Sample JSON-like string with placeholders
54
+
test('single quotes',()=>{
55
+
// Sample JSON-like string with placeholders
57
56
58
-
constinputString=`stack('test', {
59
-
input: { test: 'ok' },
60
-
outExample: { test: 'ok' }
61
-
})`;
57
+
constinputString=`stack('test', {
58
+
input: { test: 'ok' },
59
+
outExample: { test: 'ok' }
60
+
})`;
62
61
63
-
constresult=transformJSON(inputString);
62
+
constresult=transformJSON(inputString);
64
63
65
-
constexpectedOutput={
66
-
input: `{"test":"ok"}`,
67
-
outExample: {test: 'ok'},
68
-
};
64
+
constexpectedOutput={
65
+
input: `{"test":"ok"}`,
66
+
outExample: {test: 'ok'},
67
+
};
69
68
70
-
// Check if the result matches the expected output
71
-
expect(result).toEqual(expectedOutput);
72
-
});
73
-
});
69
+
// Check if the result matches the expected output
0 commit comments