Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test/proof #14

Merged
merged 26 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules/
.mesh/
.vscode/
.env
dist/
dist/
*.tgz
15 changes: 9 additions & 6 deletions .meshrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ sources:
- name: GatewaySDK
handler:
graphql:
endpoint: https://develop.protocol.mygateway.xyz/v1/graphql
endpoint: https://develop.protocol.mygateway.xyz/graphql
transforms:
- filterSchema:
- rename:
mode: bare
filters:
- Query.!transaction
- Query.!transactions
- Query.!myTransactions
renames:
- from:
type: PDAMetadata
field: status
to:
type: PDAMetadata
field: pdametadastatus

customFetch: ./custom-fetch.ts

Expand Down
55 changes: 55 additions & 0 deletions __mocks__/dataModel.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { DataModel } from '../src/data-model/data-model';
import {
dataModelStub,
dataModelMetaDataStub,
dataModelCreateStub,
} from '../test/stubs/dataModel.stub';

export const DataModelMockService = (dataModel: DataModel) => ({
createDataModelMock: jest
.spyOn(dataModel.sdk, 'createDataModel_mutation')
.mockResolvedValue({
createDataModel: dataModelStub(),
}),

getDataModelMock: jest
.spyOn(dataModel.sdk, 'dataModel_query')
.mockResolvedValue({
dataModel: dataModelStub(),
}),

getDataModelsMock: jest
.spyOn(dataModel.sdk, 'dataModels_query')
.mockResolvedValue({
dataModels: [dataModelStub()],
}),

getDataModelsCountMock: jest
.spyOn(dataModel.sdk, 'dataModelsCount_query')
.mockResolvedValue({
dataModelsCount: 10,
}),

getDataModelsMetaDataMock: jest
.spyOn(dataModel.sdk, 'dataModelsMetadata_query')
.mockResolvedValue({
dataModelsMetadata: dataModelMetaDataStub(),
}),

getIssuersByDataModelMock: jest
.spyOn(dataModel.sdk, 'issuersByDataModel_query')
.mockResolvedValue({
issuersByDataModel: [{ count: 10 }],
}),

getIssuersDataModelCountMock: jest
.spyOn(dataModel.sdk, 'issuersByDataModelCount_query')
.mockResolvedValue({
issuersByDataModelCount: 10,
}),
getTotalofIssuersByDataModelMock: jest
.spyOn(dataModel.sdk, 'getTotalofIssuersByDataModel_query')
.mockResolvedValue({
getTotalofIssuersByDataModel: 10,
}),
});
2 changes: 1 addition & 1 deletion __mocks__/dataRequestTemplate.mock.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DataRequestTemplate } from '../src/dataRequestsTemplate/dataRequestsTemplate';
import { dataRequestTemplateStub } from '../test/stubs/dataRequestTemplate.stub';

export const dataRequestTemplateMockService = (
export const DataRequestTemplateMockService = (
dataRequestTemplate: DataRequestTemplate,
) => ({
createDataRequestTemplateMock: jest
Expand Down
54 changes: 54 additions & 0 deletions __mocks__/proof.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Proof } from '../src/proof/proof';
import { proofStub, createProofMessage } from '../test/stubs/proof.stub';

export const ProofMockService = (proof: Proof) => ({
getProofMock: jest.spyOn(proof.sdk, 'proof_query').mockResolvedValue({
proof: proofStub(),
}),

createProofMock: jest
.spyOn(proof.sdk, 'createProof_mutation')
.mockResolvedValue({
createProof: proofStub(),
}),

createProofMessageMock: jest
.spyOn(proof.sdk, 'createProofMessage_mutation')
.mockResolvedValue({
createProofMessage: createProofMessage,
}),

getProofsMock: jest.spyOn(proof.sdk, 'proofs_query').mockResolvedValue({
proofs: [proofStub()],
}),

getProofsByPDAIdsMock: jest
.spyOn(proof.sdk, 'proofsByPDAIds_query')
.mockResolvedValue({
proofsByPDAIds: [proofStub()],
}),

getReceivedProofsMock: jest
.spyOn(proof.sdk, 'receivedProofs_query')
.mockResolvedValue({
receivedProofs: [proofStub()],
}),

getReceivedProofsCountMock: jest
.spyOn(proof.sdk, 'receivedProofsCount_query')
.mockResolvedValue({
receivedProofsCount: 10,
}),

getSentProofsMock: jest
.spyOn(proof.sdk, 'sentProofs_query')
.mockResolvedValue({
sentProofs: [proofStub()],
}),

getSentProofsCountMock: jest
.spyOn(proof.sdk, 'sentProofsCount_query')
.mockResolvedValue({
sentProofsCount: 10,
}),
});
56 changes: 56 additions & 0 deletions __mocks__/request.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Request } from '../src/request/request';
import { requestStub } from '../test/stubs/request.stub';

export const RequestMockService = (request: Request) => ({
createDataRequestMock: jest
.spyOn(request.sdk, 'createDataRequest_mutation')
.mockResolvedValue({
createDataRequest: requestStub(),
}),

getDataRequestMock: jest
.spyOn(request.sdk, 'dataRequest_query')
.mockResolvedValue({
dataRequest: requestStub(),
}),

getDataRequestCountMock: jest
.spyOn(request.sdk, 'dataRequestCount_query')
.mockResolvedValue({
dataRequestCount: 10,
}),

getDataRequestStatusMock: jest
.spyOn(request.sdk, 'dataRequestStatus_query')
.mockResolvedValue({
dataRequestStatus: requestStub().status,
}),

getDataRequestsMock: jest
.spyOn(request.sdk, 'dataRequests_query')
.mockResolvedValue({
dataRequests: [requestStub()],
}),

getRequestsReceivedMock: jest
.spyOn(request.sdk, 'requestsReceived_query')
.mockResolvedValue({
requestsReceived: [requestStub()],
}),

getRequestReceivedCountMock: jest
.spyOn(request.sdk, 'requestsReceivedCount_query')
.mockResolvedValue({
requestsReceivedCount: 10,
}),

getRequestsSentMock: jest
.spyOn(request.sdk, 'requestsSent_query')
.mockResolvedValue({
requestsSent: [requestStub()],
}),

getRequestsSentCountMock: jest
.spyOn(request.sdk, 'requestsSentCount_query')
.mockResolvedValue({ requestsSentCount: 10 }),
});
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
{
"name": "@Gateway-dao/js-sdk",
"version": "0.0.0",
"description": "",
"description": "A Typescript SDK for the Gateway API",
"main": "dist/src/Gateway.js",
"types": "dist/src/types.d.ts",
"types": "dist/src/Gateway.d.ts",
"scripts": {
"test": "jest",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"format": "prettier --write .",
"build": "tsc"
},
"keywords": [],
"author": "",
"keywords": [
"sdk",
"sdk-typescript",
"web3"
],
"license": "MIT",
"dependencies": {
"@graphql-mesh/cli": "^0.87.16",
"@graphql-mesh/graphql": "^0.95.8",
"@graphql-mesh/runtime": "^0.96.13",
"@graphql-mesh/transform-filter-schema": "^0.96.2",
"@graphql-mesh/runtime": "^0.96.11",
"@graphql-mesh/transform-rename": "^0.96.3",
"@solana/web3.js": "^1.87.6",
"@whatwg-node/fetch": "^0.9.14",
"@whatwg-node/fetch": "^0.9.13",
"ethers": "^5.7.2",
"graphql": "^16.8.1"
},
Expand Down
Loading
Loading