Skip to content

Commit

Permalink
Merge pull request #19 from Gateway-DAO/feat/remaining-stuff
Browse files Browse the repository at this point in the history
chore: testing codecov
  • Loading branch information
Siddharth9890 authored Jan 19, 2024
2 parents f84b388 + db2f63c commit 802e66f
Show file tree
Hide file tree
Showing 29 changed files with 4,936 additions and 1,476 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ test/*
.mesh/*
__mocks__/*
lib/*
custom-fetch.js
custom-fetch.js
coverage/*
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ node_modules/
.env
dist/
*.tgz
lib/
lib/
coverage/
24 changes: 12 additions & 12 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
- Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
- The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand Down Expand Up @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
Expand All @@ -125,4 +125,4 @@ enforcement ladder](https://github.com/mozilla/diversity).

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
https://www.contributor-covenant.org/translations.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
[![NPM version][npm-image]][npm-url]
[![NPM downloads][downloads-image]][downloads-url]
[![Join Discord][discord-image]][discord-url]
[![Build status][travis-image]][travis-url]
[![Coverage Status][coveralls-image]][coveralls-url]
[![Build status][travis-image]][test-passing]
[![Coverage Status][codecov-image]][codecov-url]

## Introduction

Expand Down Expand Up @@ -137,7 +137,6 @@ async function main() {
main();
```


## Error Handling

All the methods throw a validation error if the validation does not match for example:- invalid wallet, invalid uuid for all ids,
Expand Down Expand Up @@ -177,13 +176,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
[codecov-image]: https://codecov.io/gh/Gateway-DAO/gateway-js-sdk/graph/badge.svg?token=8N92RFGZHI
[codecov-url]: https://codecov.io/gh/Gateway-DAO/gateway-js-sdk
[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
[test-passing]: https://github.com/Gateway-DAO/gateway-js-sdk/actions/workflows/main.yml/badge.svg?branch=main
45 changes: 44 additions & 1 deletion __mocks__/auth.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,59 @@ export const AuthMockService = (auth: Auth) => ({
.mockResolvedValue({
checkUsernameAvailability: true,
}),

addEmailMock: jest.spyOn(auth.sdk, 'addEmail_mutation').mockResolvedValue({
addEmail: authStub(),
}),
addWalletMock: jest
.spyOn(auth.sdk, 'addWallet_mutation')
.mockResolvedValue({ addWallet: authStub() }),
addEmailConfirmationtMock: jest
.spyOn(auth.sdk, 'addEmailConfirmation_mutation')
.mockResolvedValue({ addEmailConfirmation: { user: authStub() } }),
addWalletConfirmationtMock: jest
.spyOn(auth.sdk, 'addWalletConfirmation_mutation')
.mockResolvedValue({ addWalletConfirmation: authStub() }),
loginEmailMock: jest
.spyOn(auth.sdk, 'loginEmail_mutation')
.mockResolvedValue({
loginEmail: {
user: authStub(),
refresh_token: authStub().existingRefreshToken,
protocol_id: authStub().id,
token: authStub().token,
},
}),
loginWalletlMock: jest
.spyOn(auth.sdk, 'loginWallet_mutation')
.mockResolvedValue({
loginWallet: {
user: authStub(),
refresh_token: authStub().existingRefreshToken,
protocol_id: authStub().id,
token: authStub().token,
},
}),
getPDAMock: jest.spyOn(auth.sdk, 'PDA_query').mockResolvedValue({
PDA: pdaStub(),
}),
createWalletNonceMock: jest
.spyOn(auth.sdk, 'createWalletNonce_mutation')
.mockResolvedValue({ createWalletNonce: authStub() }),
.mockResolvedValue({ createWalletNonce: { message: authStub().message } }),
deleteAccountMock: jest
.spyOn(auth.sdk, 'deleteAccount_mutation')
.mockResolvedValue({ deleteAccount: true }),
refreshTokenMock: jest
.spyOn(auth.sdk, 'refreshToken_mutation')
.mockResolvedValue({
refreshToken: {
user: authStub(),
refresh_token: authStub().existingRefreshToken,
protocol_id: authStub().id,
token: authStub().token,
},
}),
unregisterAuthMethodMock: jest
.spyOn(auth.sdk, 'unregisterAuthMethod_mutation')
.mockResolvedValue({ unregisterAuthMethod: true }),
});
8 changes: 7 additions & 1 deletion __mocks__/pda.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ export const PDAMockService = (pda: PDA) => ({
pdasMock: jest
.spyOn(pda.sdk, 'PDAs_query')
.mockResolvedValue({ PDAs: [pdaStub()] }),
issuedPDAMock: jest
issuedCountPDAMock: jest
.spyOn(pda.sdk, 'issuedPDAsCount_query')
.mockResolvedValue({ issuedPDAsCount: 10 }),
issuedPDAMock: jest
.spyOn(pda.sdk, 'issuedPDAs_query')
.mockResolvedValue({ issuedPDAs: [pdaStub()] }),
updatePDAMock: jest
.spyOn(pda.sdk, 'updatePDA_mutation')
.mockResolvedValue({ updatePDA: pdaStub() }),
});
2 changes: 1 addition & 1 deletion __mocks__/proof.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const ProofMockService = (proof: Proof) => ({
getProofMock: jest.spyOn(proof.sdk, 'proof_query').mockResolvedValue({
proof: proofStub(),
}),

createProofMock: jest
.spyOn(proof.sdk, 'createProof_mutation')
.mockResolvedValue({
Expand Down
34 changes: 26 additions & 8 deletions __mocks__/user.mock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { User } from '../src/user/user';
import { userStub, walletStub } from '../test/stubs/user.stub';
import {
financialTransactionsStub,
userStub,
walletStub,
} from '../test/stubs/user.stub';

export const UserMockService = (user: User) => ({
meMock: jest.spyOn(user.sdk, 'me_query').mockResolvedValue({
Expand Down Expand Up @@ -33,8 +37,7 @@ export const UserMockService = (user: User) => ({
.spyOn(user.sdk, 'updateMyProfilePicture_mutation')
.mockResolvedValue({
updateMyProfilePicture: userStub({
profilePicture:
'https://www.tryodyssey.xyz/images/campaigns/lifi/odyssey_lifi.png',
profilePicture: userStub().profilePicture,
}).profilePicture,
}),
myFinancialTransactionsCountMock: jest
Expand All @@ -45,9 +48,24 @@ export const UserMockService = (user: User) => ({
mywalletMock: jest.spyOn(user.sdk, 'myWallet_query').mockResolvedValue({
myWallet: walletStub(),
}),
// myFinancialTransactionsMock: jest
// .spyOn(user.sdk, 'myFinancialTransactions_query')
// .mockResolvedValue({
// myFinancialTransactions: userStub().
// }),
updateUserDisplayNameMock: jest
.spyOn(user.sdk, 'updateMyDisplayName_mutation')
.mockResolvedValue({
updateMyDisplayName: userStub().displayName,
}),
updateUserGatewayIdMock: jest
.spyOn(user.sdk, 'updateMyGatewayId_mutation')
.mockResolvedValue({
updateMyGatewayId: userStub(),
}),
updateUserNotificationEmaailMock: jest
.spyOn(user.sdk, 'updateNotificationEmail_mutation')
.mockResolvedValue({
updateNotificationEmail: { user: userStub() },
}),
myFinancialTransactionsMock: jest
.spyOn(user.sdk, 'myFinancialTransactions_query')
.mockResolvedValue({
myFinancialTransactions: financialTransactionsStub(),
}),
});
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
coveragePathIgnorePatterns: ['custom-fetch.js', '.mesh/*'],
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "dist/src/Gateway.js",
"types": "dist/src/Gateway.d.ts",
"scripts": {
"test": "jest",
"test": "jest --coverage",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"format": "prettier --write .",
Expand Down Expand Up @@ -50,4 +50,4 @@
"type": "git",
"url": "git+https://github.com/Gateway-DAO/gateway-js-sdk.git"
}
}
}
Loading

0 comments on commit 802e66f

Please sign in to comment.