Skip to content

Commit

Permalink
fix: fix tests and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman035 committed Dec 19, 2023
1 parent 79cb7b9 commit 47918e3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 33 additions & 0 deletions packages/examples/sdk-backend-node/chat/nftChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,40 @@ const eventlistener = async (
});
};

const skipExample = () => {
const requiredEnvVars = [
'NFT_CHAIN_ID_1',
'NFT_CONTRACT_ADDRESS_1',
'NFT_TOKEN_ID_1',
'NFT_HOLDER_WALLET_PRIVATE_KEY_1',
'NFT_PROFILE_PASSWORD_1',
'NFT_CHAIN_ID_2',
'NFT_CONTRACT_ADDRESS_2',
'NFT_TOKEN_ID_2',
'NFT_HOLDER_WALLET_PRIVATE_KEY_2',
'NFT_PROFILE_PASSWORD_2',
'NFT_CHAIN_ID_3',
'NFT_CONTRACT_ADDRESS_3',
'NFT_TOKEN_ID_3',
'NFT_HOLDER_WALLET_PRIVATE_KEY_3',
'NFT_PROFILE_PASSWORD_3',
];

for (const envVar of requiredEnvVars) {
if (!process.env[envVar]) {
return true; // Skip the example if any of the required env vars is missing
}
}

return false; // All required env vars are present, don't skip the example
};

export const runNFTChatClassUseCases = async (): Promise<void> => {
if (skipExample()) {
console.log('Skipping examples as required env vars are missing');
return;
}

const userAlice = await PushAPI.initialize(nftSigner1, {
env,
account: nftAccount1,
Expand Down
2 changes: 1 addition & 1 deletion packages/restapi/tests/lib/chat/nftChat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
colors,
uniqueNamesGenerator,
} from 'unique-names-generator';
import { PushStream } from 'packages/restapi/src/lib/pushstream/PushStream';
import { PushStream } from '../../../src/lib/pushstream/PushStream';
import { ENCRYPTION_TYPE } from '../../../src/lib/constants';

dotenv.config({ path: path.resolve(__dirname, '../../.env') });
Expand Down

0 comments on commit 47918e3

Please sign in to comment.