Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip-Carneiro committed Oct 11, 2024
1 parent db2696b commit e47155d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/suite/webview.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -931,4 +965,6 @@ describe("KdbNewConnectionView", () => {
sinon.restore();
});
});

describe("createLabel", () => {});
});

0 comments on commit e47155d

Please sign in to comment.