Skip to content

Commit 2a1b1b8

Browse files
author
Krishna Prasath D
committed
remove unnecessary formatting
1 parent b1f2198 commit 2a1b1b8

1 file changed

Lines changed: 122 additions & 19 deletions

File tree

test/src/tools/test-plan.test.ts

Lines changed: 122 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,30 @@ describe("configureTestPlanTools", () => {
185185
{ id: 102, name: "Child Suite 2", parentSuite: { id: 100 } },
186186
],
187187
},
188-
{ id: 101, name: "Child Suite 1", hasChildren: true, parentSuite: { id: 100 }, children: [{ id: 103, name: "Grandchild Suite", parentSuite: { id: 101 } }] },
189-
{ id: 102, name: "Child Suite 2", parentSuite: { id: 100 } },
190-
{ id: 103, name: "Grandchild Suite", parentSuite: { id: 101 } },
188+
{
189+
id: 101,
190+
name: "Child Suite 1",
191+
hasChildren: true,
192+
parentSuite: { id: 100 },
193+
children: [{ id: 103, name: "Grandchild Suite", parentSuite: { id: 101 } }],
194+
},
195+
{
196+
id: 102,
197+
name: "Child Suite 2",
198+
parentSuite: { id: 100 },
199+
},
200+
{
201+
id: 103,
202+
name: "Grandchild Suite",
203+
parentSuite: { id: 101 },
204+
},
191205
]);
192206

193-
const result = await handler({ project: "proj1", planId: 1 });
207+
const params = {
208+
project: "proj1",
209+
planId: 1,
210+
};
211+
const result = await handler(params);
194212

195213
expect(global.fetch).toHaveBeenCalledWith(expect.stringContaining("proj1/_apis/testplan/Plans/1/Suites?"), expect.objectContaining({ method: "GET" }));
196214
const parsed = JSON.parse(result.content[0].text);
@@ -199,8 +217,20 @@ describe("configureTestPlanTools", () => {
199217
id: 100,
200218
name: "Root Suite",
201219
children: [
202-
{ id: 101, name: "Child Suite 1", children: [{ id: 103, name: "Grandchild Suite" }] },
203-
{ id: 102, name: "Child Suite 2" },
220+
{
221+
id: 101,
222+
name: "Child Suite 1",
223+
children: [
224+
{
225+
id: 103,
226+
name: "Grandchild Suite",
227+
},
228+
],
229+
},
230+
{
231+
id: 102,
232+
name: "Child Suite 2",
233+
},
204234
],
205235
});
206236
});
@@ -213,7 +243,11 @@ describe("configureTestPlanTools", () => {
213243

214244
mockFetchSuitesResponse([{ id: 200, name: "Single Suite", hasChildren: false }]);
215245

216-
const result = await handler({ project: "proj1", planId: 2 });
246+
const params = {
247+
project: "proj1",
248+
planId: 2,
249+
};
250+
const result = await handler(params);
217251

218252
const parsed = JSON.parse(result.content[0].text);
219253
expect(parsed.testSuites).toHaveLength(1);
@@ -228,7 +262,11 @@ describe("configureTestPlanTools", () => {
228262

229263
mockFetchSuitesResponse([]);
230264

231-
const result = await handler({ project: "proj1", planId: 3 });
265+
const params = {
266+
project: "proj1",
267+
planId: 3,
268+
};
269+
const result = await handler(params);
232270

233271
const parsed = JSON.parse(result.content[0].text);
234272
expect(parsed.testSuites).toEqual([]);
@@ -241,19 +279,61 @@ describe("configureTestPlanTools", () => {
241279
const [, , , handler] = call;
242280

243281
mockFetchSuitesResponse([
244-
{ id: 300, name: "Root", hasChildren: true, children: [{ id: 301, name: "Level 1", parentSuite: { id: 300 } }] },
245-
{ id: 301, name: "Level 1", hasChildren: true, parentSuite: { id: 300 }, children: [{ id: 302, name: "Level 2", parentSuite: { id: 301 } }] },
246-
{ id: 302, name: "Level 2", hasChildren: true, parentSuite: { id: 301 }, children: [{ id: 303, name: "Level 3", parentSuite: { id: 302 } }] },
247-
{ id: 303, name: "Level 3", parentSuite: { id: 302 } },
282+
{
283+
id: 300,
284+
name: "Root",
285+
hasChildren: true,
286+
children: [{ id: 301, name: "Level 1", parentSuite: { id: 300 } }],
287+
},
288+
{
289+
id: 301,
290+
name: "Level 1",
291+
hasChildren: true,
292+
parentSuite: { id: 300 },
293+
children: [{ id: 302, name: "Level 2", parentSuite: { id: 301 } }],
294+
},
295+
{
296+
id: 302,
297+
name: "Level 2",
298+
hasChildren: true,
299+
parentSuite: { id: 301 },
300+
children: [{ id: 303, name: "Level 3", parentSuite: { id: 302 } }],
301+
},
302+
{
303+
id: 303,
304+
name: "Level 3",
305+
parentSuite: { id: 302 },
306+
},
248307
]);
249308

250-
const result = await handler({ project: "proj1", planId: 4 });
309+
const params = {
310+
project: "proj1",
311+
planId: 4,
312+
};
313+
const result = await handler(params);
251314

252315
const parsed = JSON.parse(result.content[0].text);
253316
expect(parsed.testSuites[0]).toMatchObject({
254317
id: 300,
255318
name: "Root",
256-
children: [{ id: 301, name: "Level 1", children: [{ id: 302, name: "Level 2", children: [{ id: 303, name: "Level 3" }] }] }],
319+
children: [
320+
{
321+
id: 301,
322+
name: "Level 1",
323+
children: [
324+
{
325+
id: 302,
326+
name: "Level 2",
327+
children: [
328+
{
329+
id: 303,
330+
name: "Level 3",
331+
},
332+
],
333+
},
334+
],
335+
},
336+
],
257337
});
258338
});
259339

@@ -265,7 +345,11 @@ describe("configureTestPlanTools", () => {
265345

266346
(global.fetch as jest.Mock) = jest.fn().mockRejectedValue(new Error("API Error"));
267347

268-
const result = await handler({ project: "proj1", planId: 5 });
348+
const params = {
349+
project: "proj1",
350+
planId: 5,
351+
};
352+
const result = await handler(params);
269353

270354
expect(result.isError).toBe(true);
271355
expect(result.content[0].text).toContain("Error listing test suites: API Error");
@@ -279,7 +363,12 @@ describe("configureTestPlanTools", () => {
279363

280364
mockFetchSuitesResponse([{ id: 400, name: "Suite with Token" }], "nextSuiteToken");
281365

282-
const result = await handler({ project: "proj1", planId: 6, continuationToken: "token123" });
366+
const params = {
367+
project: "proj1",
368+
planId: 6,
369+
continuationToken: "token123",
370+
};
371+
const result = await handler(params);
283372

284373
expect(global.fetch).toHaveBeenCalledWith(expect.stringContaining("continuationToken=token123"), expect.anything());
285374
const parsed = JSON.parse(result.content[0].text);
@@ -293,11 +382,25 @@ describe("configureTestPlanTools", () => {
293382
const [, , , handler] = call;
294383

295384
mockFetchSuitesResponse([
296-
{ id: 500, name: "Parent", hasChildren: true, children: [{ id: 501, name: "Child with no children", parentSuite: { id: 500 } }] },
297-
{ id: 501, name: "Child with no children", parentSuite: { id: 500 }, hasChildren: false },
385+
{
386+
id: 500,
387+
name: "Parent",
388+
hasChildren: true,
389+
children: [{ id: 501, name: "Child with no children", parentSuite: { id: 500 } }],
390+
},
391+
{
392+
id: 501,
393+
name: "Child with no children",
394+
parentSuite: { id: 500 },
395+
hasChildren: false,
396+
},
298397
]);
299398

300-
const result = await handler({ project: "proj1", planId: 7 });
399+
const params = {
400+
project: "proj1",
401+
planId: 7,
402+
};
403+
const result = await handler(params);
301404

302405
const parsed = JSON.parse(result.content[0].text);
303406
expect(parsed.testSuites[0].children[0]).toEqual({ id: 501, name: "Child with no children" });

0 commit comments

Comments
 (0)