Skip to content

Commit 751f1d7

Browse files
committed
update tests
1 parent 6c705c5 commit 751f1d7

1 file changed

Lines changed: 13 additions & 15 deletions

File tree

packages/node-sdk/test/client.test.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -945,31 +945,29 @@ describe("BucketClient", () => {
945945
it("should initialize the client", async () => {
946946
const client = new BucketClient(validOptions);
947947

948-
const cache = {
949-
refresh: vi.fn(),
950-
get: vi.fn(),
951-
};
952-
953-
vi.spyOn(client as any, "getFeaturesCache").mockReturnValue(cache);
948+
const get = vi
949+
.spyOn(client["featuresCache"], "get")
950+
.mockReturnValue(undefined);
951+
const refresh = vi
952+
.spyOn(client["featuresCache"], "refresh")
953+
.mockResolvedValue(undefined);
954954

955955
await client.initialize();
956956
await client.initialize();
957957
await client.initialize();
958958

959-
expect(cache.refresh).toHaveBeenCalledTimes(1);
960-
expect(cache.get).not.toHaveBeenCalled();
959+
expect(refresh).toHaveBeenCalledTimes(1);
960+
expect(get).not.toHaveBeenCalled();
961961
});
962962

963-
it("should set up the cache object", async () => {
963+
it("should call the backend to obtain features", async () => {
964964
const client = new BucketClient(validOptions);
965-
expect(client["featuresCache"]).toBeUndefined();
966965

967-
await client.initialize();
968-
expect(client["featuresCache"]).toBeTypeOf("object");
969-
});
966+
httpClient.get.mockResolvedValue({
967+
ok: true,
968+
status: 200,
969+
});
970970

971-
it("should call the backend to obtain features", async () => {
972-
const client = new BucketClient(validOptions);
973971
await client.initialize();
974972

975973
expect(httpClient.get).toHaveBeenCalledWith(

0 commit comments

Comments
 (0)