From bcf306b12c22fd44aa3e18919d47a6a3d3af195b Mon Sep 17 00:00:00 2001 From: Oscar Dominguez Date: Wed, 18 Sep 2024 04:44:42 +0200 Subject: [PATCH] test(parse): add test coverage when no copilot_confirmations present (#100) ### What are you trying to accomplish? Improve test coverage for `parse.js` file. Concretely for `getUserConfirmation()` method. relates to https://github.com/copilot-extensions/preview-sdk.js/issues/87 --- test/parse.test.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/test/parse.test.js b/test/parse.test.js index 902de25..b1c385a 100644 --- a/test/parse.test.js +++ b/test/parse.test.js @@ -77,7 +77,7 @@ test("verifyAndParseRequest()", async (t) => { "content-type": "application/json", "x-request-id": "", }, - }, + } ); const testRequest = defaultRequest.defaults({ request: { fetch: fetchMock }, @@ -132,6 +132,21 @@ test("getUserConfirmation()", (t) => { id: "some-confirmation-id", metadata: { someConfirmationMetadata: "value" }, }, - result, + result ); }); + +test("getUserConfirmation() with no copilot confirmations", (t) => { + const payload = { + messages: [ + { + content: "Some previous message", + }, + { + content: "Hello, world!", + }, + ], + }; + const result = getUserConfirmation(payload); + t.deepEqual(undefined, result); +});