From e47155d14359e9a7c10d1386becc7e4024c37e87 Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Fri, 11 Oct 2024 11:10:09 +0100 Subject: [PATCH] add tests --- test/suite/webview.test.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/suite/webview.test.ts b/test/suite/webview.test.ts index ac777ccf..1bed0d54 100644 --- a/test/suite/webview.test.ts +++ b/test/suite/webview.test.ts @@ -896,6 +896,40 @@ describe("KdbNewConnectionView", () => { }); }); + describe("createLabel", () => { + let clock: sinon.SinonFakeTimers; + + beforeEach(() => { + clock = sinon.useFakeTimers(); + }); + + afterEach(() => { + clock.restore(); + }); + + it("should post a message and update labels after timeout", () => { + const api = acquireVsCodeApi(); + const postMessageStub = sinon.stub(api, "postMessage"); + const closeModalStub = sinon.stub(view, "closeModal"); + + view.newLblName = "Test Label"; + view.newLblColorName = "Test Color"; + view.labels = []; + + view.createLabel(); + + sinon.assert.calledOnce(postMessageStub); + + // Avança o tempo em 500ms + clock.tick(500); + + assert.equal(view.labels[0], "Test Label"); + sinon.assert.calledOnce(closeModalStub); + + sinon.restore(); + }); + }); + describe("edit", () => { const editConn: EditConnectionMessage = { connType: 0, @@ -931,4 +965,6 @@ describe("KdbNewConnectionView", () => { sinon.restore(); }); }); + + describe("createLabel", () => {}); });