Skip to content

Commit

Permalink
fix: all query tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cgilbe27 committed Aug 2, 2024
1 parent efc0023 commit 6af3955
Show file tree
Hide file tree
Showing 8 changed files with 564 additions and 5 deletions.
88 changes: 88 additions & 0 deletions src/sdk/query/devgas.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { QueryClient } from "@cosmjs/stargate"
import * as query from "../../protojs/nibiru/devgas/v1/query"
import { setupDevgasExtension } from "."

describe("setupDevgasExtension", () => {
const mockBaseQueryClient = {} as QueryClient

jest.spyOn(query, "QueryClientImpl").mockReturnValue({
FeeShare: jest.fn().mockResolvedValue({ feeShare: "Test" }),
FeeSharesByWithdrawer: jest
.fn()
.mockResolvedValue({ feeSharesByWithdrawer: "Test" }),
FeeShares: jest.fn().mockResolvedValue({ feeShares: "Test" }),
Params: jest.fn().mockResolvedValue({ params: "Test" }),
} as unknown as query.QueryClientImpl)

test("should setup extension correctly", () => {
const extension = setupDevgasExtension(mockBaseQueryClient)

expect(extension).toBeDefined()
expect(extension.feeShare).toBeInstanceOf(Function)
expect(extension.feeSharesByWithdrawer).toBeInstanceOf(Function)
expect(extension.feeShares).toBeInstanceOf(Function)
expect(extension.params).toBeInstanceOf(Function)
})

describe("devgas.feeShare", () => {
test("should call QueryFeeShareRequest and return the response", async () => {
const queryFeeShareRequest = jest
.spyOn(query.QueryFeeShareRequest, "fromPartial")
.mockReturnValue({} as query.QueryFeeShareRequest)

const extension = setupDevgasExtension(mockBaseQueryClient)
const result = await extension.feeShare({ contractAddress: "" })
expect(queryFeeShareRequest).toHaveBeenCalledWith({
contractAddress: "",
})
expect(result).toEqual({ feeShare: "Test" })
})
})

describe("devgas.feeSharesByWithdrawer", () => {
test("should call QueryFeeSharesByWithdrawerRequest and return the response", async () => {
const queryFeeSharesByWithdrawerRequest = jest
.spyOn(query.QueryFeeSharesByWithdrawerRequest, "fromPartial")
.mockReturnValue({} as query.QueryFeeSharesByWithdrawerRequest)

const extension = setupDevgasExtension(mockBaseQueryClient)
const result = await extension.feeSharesByWithdrawer({
withdrawerAddress: "",
})
expect(queryFeeSharesByWithdrawerRequest).toHaveBeenCalledWith({
withdrawerAddress: "",
})
expect(result).toEqual({ feeSharesByWithdrawer: "Test" })
})
})

describe("devgas.feeShares", () => {
test("should call QueryFeeSharesRequest and return the response", async () => {
const queryFeeSharesRequest = jest
.spyOn(query.QueryFeeSharesRequest, "fromPartial")
.mockReturnValue({} as query.QueryFeeSharesRequest)

const extension = setupDevgasExtension(mockBaseQueryClient)
const result = await extension.feeShares({
deployer: "",
})
expect(queryFeeSharesRequest).toHaveBeenCalledWith({
deployer: "",
})
expect(result).toEqual({ feeShares: "Test" })
})
})

describe("devgas.params", () => {
test("should call QueryParamsRequest and return the response", async () => {
const queryParamsRequest = jest
.spyOn(query.QueryParamsRequest, "fromPartial")
.mockReturnValue({} as query.QueryParamsRequest)

const extension = setupDevgasExtension(mockBaseQueryClient)
const result = await extension.params({})
expect(queryParamsRequest).toHaveBeenCalledWith({})
expect(result).toEqual({ params: "Test" })
})
})
})
2 changes: 1 addition & 1 deletion src/sdk/query/epochs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("setupEpochsExtension", () => {
}),
} as unknown as query.QueryClientImpl)

test("should setup epochs extension correctly", () => {
test("should setup extension correctly", () => {
const extension = setupEpochsExtension(mockBaseQueryClient)

expect(extension).toBeDefined()
Expand Down
Loading

0 comments on commit 6af3955

Please sign in to comment.