diff --git a/.eslintignore b/.eslintignore index fe56ecd..8294af9 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,5 +2,5 @@ jest.config.js test/* .mesh/* __mocks__/* -dist/* +lib/* custom-fetch.js \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c6d7447..d5da681 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -22,3 +22,7 @@ jobs: run: pnpm format - name: Test project run: pnpm test + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitignore b/.gitignore index 7ea98f5..a55cdd6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ node_modules/ .vscode/ .env dist/ -*.tgz \ No newline at end of file +*.tgz +lib/ \ No newline at end of file diff --git a/README.md b/README.md index 0760b09..04b4f31 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,11 @@ # Gateway Javascript SDK - +[![Coverage Status][coveralls-image]][coveralls-url] ## Introduction @@ -22,7 +23,7 @@ A TypeScript SDK for the Gateway API. This library is built with TypeScript deve ## Installing ``` -pnpm add @Gateway-dao-js-sdk +pnpm add @gateway/sdk ``` ## Gateway Client @@ -30,7 +31,7 @@ pnpm add @Gateway-dao-js-sdk To setup the gateway client we will authenticate with a bearer-token and a Api key as follows ```typescript -import { Gateway } from '@Gateway-dao-js-sdk'; +import { Gateway } from '@gateway/sdk'; const gateway = new Gateway({ apiKey: 'your-api-key', @@ -48,7 +49,7 @@ Make sure to add try catch blocks around methods to catch all the validation and ### Creating a PDA ```typescript -import { Gateway, UserIdentifierType } from '@Gateway-dao-js-sdk'; +import { Gateway, UserIdentifierType } from '@gateway/sdk'; const gateway = new Gateway({ apiKey: 'your-api-key', token: 'your-token' }); @@ -78,7 +79,7 @@ main(); ### Getting a Organization ```typescript -import { Gateway } from '@Gateway-dao-js-sdk'; +import { Gateway } from '@gateway/sdk'; const gateway = new Gateway({ apiKey: 'your-api-key', token: 'your-token' }); @@ -102,7 +103,7 @@ main(); ### Create a Data request template ```typescript -import { Gateway } from '@Gateway-dao-js-sdk'; +import { Gateway } from '@gateway/sdk'; const gateway = new Gateway({ apiKey: 'your-api-key', token: 'your-token' }); @@ -176,10 +177,13 @@ If you want to support the active development of the SDK [Please talk to us on D pnpm test ``` +[gateway-package-name]: @gateway/sdk [npm-image]: https://img.shields.io/npm/v/docusign-esign.svg?style=flat [npm-url]: https://npmjs.org/package/@Gateway-dao-js-sdk [downloads-image]: https://img.shields.io/npm/dm/docusign-esign.svg?style=flat [downloads-url]: https://npmjs.org/package/docusign-esign [coveralls-image]: https://coveralls.io/repos/github/docusign/@Gateway-dao-js-sdk/badge.svg?branch=master [coveralls-url]: https://coveralls.io/github/docusign/@Gateway-dao-js-sdk?branch=master +[discord-image]: https://img.shields.io/discord/733027681184251937.svg?style=flat&label=Join%20Community&color=7289DA +[discord-url]: https://discord.gg/tgt3KjcHGs [github-url]: https://github.com/Gateway-DAO/javascript-sdk diff --git a/__mocks__/dataRequestTemplate.mock.ts b/__mocks__/dataRequestTemplate.mock.ts index 590bd39..c09a372 100644 --- a/__mocks__/dataRequestTemplate.mock.ts +++ b/__mocks__/dataRequestTemplate.mock.ts @@ -17,9 +17,26 @@ export const DataRequestTemplateMockService = ( getDataRequestTemplatesMock: jest .spyOn(dataRequestTemplate.sdk, 'dataRequestTemplates_query') .mockResolvedValue({ dataRequestTemplates: [dataRequestTemplateStub()] }), - getDataRequestsTemplateCount: jest + getDataRequestsTemplateCountMock: jest .spyOn(dataRequestTemplate.sdk, 'dataRequestTemplatesCount_query') .mockResolvedValue({ dataRequestTemplatesCount: 10, }), + getDataRequestsTemplatesMetadataMock: jest + .spyOn(dataRequestTemplate.sdk, 'dataRequestTemplatesMetadata_query') + .mockResolvedValue({ + dataRequestTemplatesMetadata: { + tags: [dataRequestTemplateStub().tags[0]], + }, + }), + getVerifiersByDataRequestTemplateMock: jest + .spyOn(dataRequestTemplate.sdk, 'verifiersByDataRequestTemplate_query') + .mockResolvedValue({ + verifiersByDataRequestTemplate: [], + }), + getVerifiersByDataRequestTemplateCountMock: jest + .spyOn(dataRequestTemplate.sdk, 'verifiersByDataRequestTemplateCount_query') + .mockResolvedValue({ + verifiersByDataRequestTemplateCount: 10, + }), }); diff --git a/__mocks__/user.mock.ts b/__mocks__/user.mock.ts index b0a8f3b..27d43e5 100644 --- a/__mocks__/user.mock.ts +++ b/__mocks__/user.mock.ts @@ -1,7 +1,5 @@ -import { Organization } from '../src/organization/organization'; import { User } from '../src/user/user'; -import { organizationStub } from '../test/stubs/organization.stub'; -import { userStub } from '../test/stubs/user.stub'; +import { userStub, walletStub } from '../test/stubs/user.stub'; export const UserMockService = (user: User) => ({ meMock: jest.spyOn(user.sdk, 'me_query').mockResolvedValue({ @@ -39,4 +37,17 @@ export const UserMockService = (user: User) => ({ 'https://www.tryodyssey.xyz/images/campaigns/lifi/odyssey_lifi.png', }).profilePicture, }), + myFinancialTransactionsCountMock: jest + .spyOn(user.sdk, 'myFinancialTransactionsCount_query') + .mockResolvedValue({ + myFinancialTransactionsCount: 10, + }), + mywalletMock: jest.spyOn(user.sdk, 'myWallet_query').mockResolvedValue({ + myWallet: walletStub(), + }), + // myFinancialTransactionsMock: jest + // .spyOn(user.sdk, 'myFinancialTransactions_query') + // .mockResolvedValue({ + // myFinancialTransactions: userStub(). + // }), }); diff --git a/package.json b/package.json index 8a9274a..e2990c1 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@Gateway-dao/js-sdk", + "name": "@gateway/sdk", "version": "0.0.0", "description": "A Typescript SDK for the Gateway API", "main": "dist/src/Gateway.js", @@ -50,4 +50,4 @@ "type": "git", "url": "git+https://github.com/Gateway-DAO/gateway-js-sdk.git" } -} +} \ No newline at end of file diff --git a/src/Gateway.ts b/src/Gateway.ts index 55c7d5f..6cf59be 100644 --- a/src/Gateway.ts +++ b/src/Gateway.ts @@ -7,6 +7,14 @@ import { Proof } from './proof/proof'; import { Request } from './request/request'; import { DataModel } from './data-model/data-model'; import { User } from './user/user'; +export { + AuthType, + Chain, + OrganizationIdentifierType, + PDAStatus, + UserIdentifierType, + OrganizationRole, +} from './types'; export class Gateway { private sdk: Sdk; diff --git a/src/data-model/data-model.ts b/src/data-model/data-model.ts index 1d31a05..4b13b1a 100644 --- a/src/data-model/data-model.ts +++ b/src/data-model/data-model.ts @@ -7,9 +7,6 @@ import { import { errorHandler } from '../utils/errorHandler'; import { isUUIDValid, validateObjectProperties } from '../utils/validators'; -/* The `DataModel` class is a TypeScript class that provides methods for creating and retrieving data -models. */ - export class DataModel { public sdk: Sdk; diff --git a/src/dataRequestsTemplate/dataRequestsTemplate.ts b/src/dataRequestsTemplate/dataRequestsTemplate.ts index ae85e12..f52d215 100644 --- a/src/dataRequestsTemplate/dataRequestsTemplate.ts +++ b/src/dataRequestsTemplate/dataRequestsTemplate.ts @@ -25,7 +25,7 @@ export class DataRequestTemplate { async createDataRequestTemplate(templateInput: TemplateSchemaInput) { try { validateObjectProperties(templateInput); - return this.sdk.createDataRequestTemplate_mutation({ + return await this.sdk.createDataRequestTemplate_mutation({ input: templateInput, }); } catch (error) { @@ -43,7 +43,7 @@ export class DataRequestTemplate { async getDataRequestTemplate(id: string) { try { isUUIDValid(id); - return this.sdk.dataRequestTemplate_query({ id }); + return await this.sdk.dataRequestTemplate_query({ id }); } catch (error) { throw new Error(errorHandler(error)); } @@ -61,7 +61,7 @@ export class DataRequestTemplate { variables?: dataRequestTemplates_queryQueryVariables, ) { try { - return this.sdk.dataRequestTemplates_query(variables); + return await this.sdk.dataRequestTemplates_query(variables); } catch (error) { throw new Error(errorHandler(error)); } @@ -83,4 +83,48 @@ export class DataRequestTemplate { throw new Error(errorHandler(error)); } } + + /** + * The function `getDataRequestsTemplatesMetadata` gets metadat of template + * to the SDK and returns the result, or throws an error if something goes wrong. + * @returns the result of the `dataRequestTemplatesMetadata_queryQuery` method call. + */ + async getDataRequestsTemplatesMetadata() { + try { + return await this.sdk.dataRequestTemplatesMetadata_query(); + } catch (error) { + throw new Error(errorHandler(error)); + } + } + + /** + * The function `getVerifiersByDataRequestTemplate` gets verifier for a data request template + * to the SDK and returns the result, or throws an error if something goes wrong. + * @param {string} id - The variables is a id of the template + * @returns the result of the `verifiersByDataRequestTemplate_queryQuery` method call. + */ + async getVerifiersByDataRequestTemplate(id: string) { + try { + isUUIDValid(id); + return await this.sdk.verifiersByDataRequestTemplate_query({ id }); + } catch (error) { + throw new Error(errorHandler(error)); + } + } + + /** + * The function `getVerifiersByDataRequestTemplateCount` gets count of recently made transactions + * to the SDK and returns the result, or throws an error if something goes wrong. + * @param {string} id - The variables is a id of the template + * @returns the result of the `verifiersByDataRequestTemplateCount_queryQuery` method call. + */ + async getVerifiersByDataRequestTemplateCount(id: string) { + try { + isUUIDValid(id); + return (await this.sdk.verifiersByDataRequestTemplateCount_query({ id })) + .verifiersByDataRequestTemplateCount; + } catch (error) { + throw new Error(errorHandler(error)); + } + } } diff --git a/src/organization/organization.ts b/src/organization/organization.ts index b24f178..c1161df 100644 --- a/src/organization/organization.ts +++ b/src/organization/organization.ts @@ -31,7 +31,7 @@ export class Organization { async createOrganization(organizationInput: CreateOrganizationInput) { try { validateObjectProperties(organizationInput); - return this.sdk.createOrganization_mutation({ + return await this.sdk.createOrganization_mutation({ input: organizationInput, }); } catch (error) { @@ -48,7 +48,7 @@ export class Organization { */ async addMemberToOrganization(memberInput: MemberInput) { try { - return this.sdk.addMemberToOrganization_mutation({ + return await this.sdk.addMemberToOrganization_mutation({ input: memberInput, }); } catch (error) { @@ -66,7 +66,7 @@ export class Organization { */ async changeMemberRole(memberInput: MemberInput) { try { - return this.sdk.changeMemberRole_mutation({ input: memberInput }); + return await this.sdk.changeMemberRole_mutation({ input: memberInput }); } catch (error) { throw new Error(errorHandler(error)); } @@ -101,7 +101,7 @@ export class Organization { async updateOrganization(updatedOrganization: UpdateOrganizationInput) { try { validateObjectProperties(updatedOrganization); - return this.sdk.updateOrganization_mutation({ + return await this.sdk.updateOrganization_mutation({ input: updatedOrganization, }); } catch (error) { @@ -123,7 +123,7 @@ export class Organization { async getOrganization(type: OrganizationIdentifierType, value: string) { try { isStringValid(value); - return this.sdk.organization_query({ input: { type, value } }); + return await this.sdk.organization_query({ input: { type, value } }); } catch (error) { throw new Error(errorHandler(error)); } diff --git a/src/pda/pda.ts b/src/pda/pda.ts index 063cccc..0e264e3 100644 --- a/src/pda/pda.ts +++ b/src/pda/pda.ts @@ -27,7 +27,7 @@ export class PDA { async getPDA(id: string) { try { isUUIDValid(id); - return this.sdk.PDA_query({ id }); + return await this.sdk.PDA_query({ id }); } catch (error) { throw new Error(errorHandler(error)); } @@ -41,7 +41,7 @@ export class PDA { * of type `FilterPDAInput`. * @returns a Promise that resolves to a number. */ - async getPDACount(filter: FilterPDAInput = {}) { + async getPDACount(filter?: FilterPDAInput) { try { return (await this.sdk.PDACount_query({ filter })).PDACount; } catch (error) { @@ -52,12 +52,12 @@ export class PDA { /** * The function `getPDAs` retrieves PDAs based on the provided filter, order, skip, and take * parameters. - * @param {PDAFilter} - - `filter`: An object that contains filter criteria for the query. + * @param {PDAs_queryQueryVariables} - - `filter`: An object that contains filter criteria for the query. * @returns a Promise that resolves to a value of type PDAs_queryQuery. */ async getPDAs(variables?: PDAs_queryQueryVariables) { try { - return this.sdk.PDAs_query(variables); + return await this.sdk.PDAs_query(variables); } catch (error) { throw new Error(errorHandler(error)); } @@ -66,13 +66,13 @@ export class PDA { /** * The function `getIssuedPDAs` retrieves issued PDAs based on the provided filter, order, skip, and * take parameters. - * @param {PDAFilter} - - `filter`: An object that contains filter criteria for the query. It is + * @param {issuedPDAs_queryQueryVariables} - - `filter`: An object that contains filter criteria for the query. It is * used to specify conditions that the returned PDAs must meet. * @returns a Promise that resolves to an object of type `issuedPDAs_queryQuery`. */ async getIssuedPDAs(variables?: issuedPDAs_queryQueryVariables) { try { - return this.sdk.issuedPDAs_query(variables); + return await this.sdk.issuedPDAs_query(variables); } catch (error) { throw new Error(errorHandler(error)); } @@ -93,21 +93,6 @@ export class PDA { } } - /** - * The function `myPDACount` is an asynchronous function that returns the count of myPDAs based on an - * optional filter. - * @param {FilterPDAInput} [filter] - The `filter` parameter is an optional input that can be used to - * filter the results of the query. It is of type `FilterPDAInput`. - * @returns a Promise that resolves to a number. - */ - async myPDACount(filter?: FilterPDAInput) { - try { - return (await this.sdk.myPDACount_query({ filter })).myPDACount; - } catch (error) { - throw new Error(errorHandler(error)); - } - } - /** * The function `changePDAStatus` is an asynchronous function that takes an `id` and a `status` as * parameters and returns a Promise that resolves to a `changePDAStatus_mutationMutation` object. @@ -117,7 +102,7 @@ export class PDA { async changePDAStatus({ id, status }: { id: string; status: PDAStatus }) { try { isUUIDValid(id); - return this.sdk.changePDAStatus_mutation({ input: { id, status } }); + return await this.sdk.changePDAStatus_mutation({ input: { id, status } }); } catch (error) { throw new Error(errorHandler(error)); } @@ -132,7 +117,7 @@ export class PDA { async createPDA(pdaInput: CreatePDAInput) { try { validateObjectProperties(pdaInput); - return this.sdk.createPDA_mutation({ input: pdaInput }); + return await this.sdk.createPDA_mutation({ input: pdaInput }); } catch (error) { throw new Error(errorHandler(error)); } @@ -150,7 +135,7 @@ export class PDA { async updatePDA(updatedPDA: UpdatePDAInput) { try { validateObjectProperties(updatedPDA); - return this.sdk.updatePDA_mutation({ input: updatedPDA }); + return await this.sdk.updatePDA_mutation({ input: updatedPDA }); } catch (error) { throw new Error(errorHandler(error)); } diff --git a/src/types.ts b/src/types.ts index 610d2e2..58b2b9a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,3 @@ -import { FilterPDAInput } from '../.mesh'; - export enum UserIdentifierType { EMAIL = 'EMAIL', EVM = 'EVM', @@ -15,13 +13,6 @@ export enum PDAStatus { 'Valid' = 'Valid', } -export type PDAFilter = { - filter?: FilterPDAInput; - order?: JSON; - skip?: number; - take?: number; -}; - export enum OrganizationIdentifierType { GATEWAY_ID = 'GATEWAY_ID', ORG_ID = 'ORG_ID', diff --git a/src/user/user.ts b/src/user/user.ts index 5a3f7d5..aa5aabd 100644 --- a/src/user/user.ts +++ b/src/user/user.ts @@ -4,13 +4,17 @@ import { FilterPDAInput, Sdk, UpdateUserInput, + myFinancialTransactionsCount_queryQueryVariables, + myFinancialTransactions_queryQueryVariables, myPDAs_queryQueryVariables, + myTransactions_queryQueryVariables, } from '../../.mesh'; import { UserIdentifierType } from '../types'; import { errorHandler } from '../utils/errorHandler'; import { isEmailValid, isStringValid, + isUUIDValid, validateObjectProperties, } from '../utils/validators'; @@ -73,9 +77,9 @@ export class User { } /** - * The function `myPDAs` is an asynchronous function that takes in a `PDAFilter` object and returns a + * The function `myPDAs` is an asynchronous function that takes in a `myPDAs_queryQueryVariables` object and returns a * promise that resolves to a `myPDAs_queryQuery` object. - * @param {PDAFilter} - - `filter`: An object that contains filter criteria for the query. + * @param {myPDAs_queryQueryVariables} - - `filter`: An object that contains filter criteria for the query. * @returns a Promise that resolves to a value of type `myPDAs_queryQuery`. */ async myPDAs(variables?: myPDAs_queryQueryVariables) { @@ -121,6 +125,70 @@ export class User { } } + /** + * The function `myFinancialTransactions` gets recently made financial transactions + * to the SDK and returns the result, or throws an error if something goes wrong. + * @param {myFinancialTransactionsCount_queryQueryVariables} variables - The variables is a complex filter type + * @returns the result of the `myFinancialTransactions_queryQuery` method call. + */ + async myFinancialTransactions( + variables?: myFinancialTransactions_queryQueryVariables, + ) { + try { + if (variables?.organizationId) isUUIDValid(variables.organizationId); + return await this.sdk.myFinancialTransactions_query(variables); + } catch (error) { + throw new Error(errorHandler(error)); + } + } + + /** + * The function `myFinancialTransactionsCount` gets count of recently made transactions + * to the SDK and returns the result, or throws an error if something goes wrong. + * @param {myFinancialTransactionsCount_queryQueryVariables} variables - The variables is a complex filter type + * @returns the result of the `myFinancialTransactionsCount_queryQuery` method call. + */ + async myFinancialTransactionsCount( + variables?: myFinancialTransactionsCount_queryQueryVariables, + ) { + try { + if (variables?.organizationId) isUUIDValid(variables.organizationId); + return (await this.sdk.myFinancialTransactionsCount_query(variables)) + .myFinancialTransactionsCount; + } catch (error) { + throw new Error(errorHandler(error)); + } + } + + /** + * The function `myTransactions_query` gets recently made transactions + * to the SDK and returns the result, or throws an error if something goes wrong. + * @param {myTransactions_queryQueryVariables} variables - The variables is a complex filter type + * @returns the result of the `myTransactions_queryQuery` method call. + */ + async myTransactions(variables?: myTransactions_queryQueryVariables) { + try { + return await this.sdk.myTransactions_query(variables); + } catch (error) { + throw new Error(errorHandler(error)); + } + } + + /** + * The function `myWallet` gets wallet summary by making a query request + * to the SDK and returns the result, or throws an error if something goes wrong. + * @param {string} organizationId - The organizationId parameter is a string that represents the org id + * @returns the result of the `myWallet_queryQuery` method call. + */ + async myWallet(organizationId?: string) { + try { + if (organizationId) isUUIDValid(organizationId); + return await this.sdk.myWallet_query({ organizationId }); + } catch (error) { + throw new Error(errorHandler(error)); + } + } + /** * The function `updateUser` updates a user's information and returns the updated user. * @param {UpdateUserInput} updatedUser - The `updatedUser` parameter is an object of type diff --git a/test/dataRequestsTemplate.test.ts b/test/dataRequestsTemplate.test.ts index 95c8def..21cb715 100644 --- a/test/dataRequestsTemplate.test.ts +++ b/test/dataRequestsTemplate.test.ts @@ -59,12 +59,51 @@ describe('DATA REQUESTS TEMPLATE TESTING', () => { }); it('get data request templates count', async () => { - const { getDataRequestsTemplateCount } = + const { getDataRequestsTemplateCountMock } = DataRequestTemplateMockService(dataRequestTemplate); const count = await dataRequestTemplate.getDataRequestsTemplateCount(); expect(count).toBeGreaterThan(0); - expect(getDataRequestsTemplateCount).toHaveBeenCalled(); + expect(getDataRequestsTemplateCountMock).toHaveBeenCalled(); + }); + + it('get data request templates metadata', async () => { + const { getDataRequestsTemplatesMetadataMock } = + DataRequestTemplateMockService(dataRequestTemplate); + + const { dataRequestTemplatesMetadata } = + await dataRequestTemplate.getDataRequestsTemplatesMetadata(); + + expect(dataRequestTemplatesMetadata.tags.length).toBe( + dataRequestTemplateStub().tags.length, + ); + expect(getDataRequestsTemplatesMetadataMock).toHaveBeenCalled(); + }); + + it('get verifiers by data request templates id', async () => { + const { getVerifiersByDataRequestTemplateMock } = + DataRequestTemplateMockService(dataRequestTemplate); + + const { verifiersByDataRequestTemplate } = + await dataRequestTemplate.getVerifiersByDataRequestTemplate( + dataRequestTemplateStub().id, + ); + + expect(verifiersByDataRequestTemplate).toBeDefined(); + expect(getVerifiersByDataRequestTemplateMock).toHaveBeenCalled(); + }); + + it('get verifiers count by data request templates', async () => { + const { getVerifiersByDataRequestTemplateCountMock } = + DataRequestTemplateMockService(dataRequestTemplate); + + const count = + await dataRequestTemplate.getVerifiersByDataRequestTemplateCount( + dataRequestTemplateStub().id, + ); + + expect(count).toBeGreaterThan(0); + expect(getVerifiersByDataRequestTemplateCountMock).toHaveBeenCalled(); }); }); diff --git a/test/stubs/dataRequestTemplate.stub.ts b/test/stubs/dataRequestTemplate.stub.ts index 24e033d..89d805d 100644 --- a/test/stubs/dataRequestTemplate.stub.ts +++ b/test/stubs/dataRequestTemplate.stub.ts @@ -52,3 +52,4 @@ export const dataRequestTemplateCreateStub = (): TemplateSchemaInput => ({ }, ], }); + diff --git a/test/stubs/user.stub.ts b/test/stubs/user.stub.ts index 982dd55..d1431b7 100644 --- a/test/stubs/user.stub.ts +++ b/test/stubs/user.stub.ts @@ -1,4 +1,4 @@ -import { User } from '../../.mesh'; +import { User, Wallet } from '../../.mesh'; export const userStub = (overrideUser?: Partial): User => ({ id: 'f47ac10b-58cc-4372-a567-0e02b2c3d479', @@ -23,3 +23,33 @@ export const userStub = (overrideUser?: Partial): User => ({ 'https://www.tryodyssey.xyz/images/campaigns/lifi/odyssey_lifi.png', ...overrideUser, }); + +export const walletStub = (): Wallet => ({ + balance: 3.175, + moneyIn: 5, + moneyInSummary: [ + { + action: 'MONEY_DEPOSIT', + amount: 5, + }, + ], + moneyOut: -1.825, + moneyOutSummary: [ + { + action: 'PDA_ISSUANCE', + amount: -0.39, + }, + { + action: 'PDA_STATUS_CHANGE', + amount: -0.085, + }, + { + action: 'REQUEST_TEMPLATE_CREATE', + amount: -0.7000000000000001, + }, + { + action: 'DATAMODEL_CREATE', + amount: -0.65, + }, + ], +}); diff --git a/test/user.test.ts b/test/user.test.ts index 2513c06..8b525df 100644 --- a/test/user.test.ts +++ b/test/user.test.ts @@ -2,7 +2,7 @@ import { getMeshSDK } from '../.mesh'; import { UserMockService } from '../__mocks__/user.mock'; import { UserIdentifierType } from '../src/types'; import { User } from '../src/user/user'; -import { userStub } from './stubs/user.stub'; +import { userStub, walletStub } from './stubs/user.stub'; let user: User; @@ -75,6 +75,42 @@ describe('USER SERVICE TESTING', () => { expect(myDataRequestTemplatesCountMock).toHaveBeenCalled(); }); + // it('my financial transactions', async () => { + // const { myDataRequestTemplatesCountMock } = UserMockService(user); + + // const count = await user.myFinancialTransactions(); + + // expect(count).toBeGreaterThanOrEqual(0); + // expect(myDataRequestTemplatesCountMock).toHaveBeenCalled(); + // }); + + it('my financial transactions count', async () => { + const { myFinancialTransactionsCountMock } = UserMockService(user); + + const count = await user.myFinancialTransactionsCount(); + + expect(count).toBeGreaterThanOrEqual(0); + expect(myFinancialTransactionsCountMock).toHaveBeenCalled(); + }); + + // it('my transactions', async () => { + // const { myDataRequestTemplatesCountMock } = UserMockService(user); + + // const count = await user.myTransactions(); + + // expect(count).toBeGreaterThanOrEqual(0); + // expect(myDataRequestTemplatesCountMock).toHaveBeenCalled(); + // }); + + it('my wallet', async () => { + const { mywalletMock } = UserMockService(user); + + const { myWallet } = await user.myWallet(); + + expect(myWallet.balance).toBe(walletStub().balance); + expect(mywalletMock).toHaveBeenCalled(); + }); + it('update user', async () => { const { updateUserMock } = UserMockService(user); diff --git a/tsconfig.json b/tsconfig.json index 826fdc2..13cecb4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,7 @@ "skipLibCheck": true, "allowJs": true, "typeRoots": ["./typings", "./node_modules/@types/"], - "outDir": "./dist", - "declaration": true + "outDir": "lib", + "declaration": true, } }