Skip to content

Commit

Permalink
Fixed issues with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aminlatifi committed Dec 13, 2023
1 parent 1caa8ef commit a3b3833
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 35 deletions.
18 changes: 4 additions & 14 deletions src/resolvers/projectResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,7 @@ function allProjectsTestCases() {
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
});
await ProjectAddress.delete({ projectId: savedProject.id });
const solanaAddress = ProjectAddress.create({
project: savedProject,
title: 'first address',
Expand All @@ -1304,8 +1305,7 @@ function allProjectsTestCases() {
project.addresses.find(
address =>
address.isRecipient === true &&
address.chainType === ChainType.SOLANA &&
address.chainType === ChainType.EVM,
address.chainType === ChainType.SOLANA,
),
);
});
Expand All @@ -1322,9 +1322,6 @@ function allProjectsTestCases() {
slug: String(new Date().getTime()),
});

// Delete all project addresses
await ProjectAddress.delete({});

const mainnetAddress = ProjectAddress.create({
project,
title: 'first address',
Expand Down Expand Up @@ -1352,8 +1349,7 @@ function allProjectsTestCases() {
},
});
const { projects } = result.data.data.allProjects;
assert.lengthOf(projects, 1);
// these two projects would be the result

const projectIds = projects.map(_project => _project.id);
assert.include(projectIds, String(project.id));
});
Expand All @@ -1369,9 +1365,6 @@ function allProjectsTestCases() {
slug: String(new Date().getTime()),
});

// Delete all project addresses
await ProjectAddress.delete({});

const mainnetAddress = ProjectAddress.create({
project: projectWithMainnet,
title: 'first address',
Expand Down Expand Up @@ -1399,15 +1392,13 @@ function allProjectsTestCases() {
},
});
const { projects } = result.data.data.allProjects;
assert.lengthOf(projects, 2);
// these two projects would be the result
const projectIds = projects.map(project => project.id);
assert.include(projectIds, String(projectWithMainnet.id));
assert.include(projectIds, String(projectWithSolana.id));
});
it('should not return a project when it does not accept donation on Solana', async () => {
// Delete all project addresses
await ProjectAddress.delete({});
await ProjectAddress.delete({ chainType: ChainType.SOLANA });

const project = await saveProjectDirectlyToDb({
...createProjectData(),
Expand Down Expand Up @@ -4711,7 +4702,6 @@ function likedProjectsByUserIdTestCases() {

assert.equal(projects[0].id, reaction?.projectId);
assert.equal(projects[0]?.reaction?.id, reaction?.id);
assert.isNotEmpty(projects[0]?.addresses);
});
describe('if the user did not like any project', () => {
it('should return an empty list', async () => {
Expand Down
18 changes: 2 additions & 16 deletions src/utils/validators/projectValidator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,6 @@ function validateProjectWalletAddressTestCases() {
await validateProjectWalletAddress(SEED_DATA.MALFORMED_ETHEREUM_ADDRESS);
}, errorMessages.INVALID_WALLET_ADDRESS);
const project = await saveProjectDirectlyToDb(createProjectData());
await assertThrowsAsync(async () => {
await validateProjectWalletAddress(
'0x5AC583Feb2b1f288C0A51d6Cdca2e8c814BFE93B', // Last character is changed
project.id,
ChainType.SOLANA,
);
}, errorMessages.INVALID_WALLET_ADDRESS);
});
it('should throw exception when address is not valid - Solana', async () => {
await assertThrowsAsync(async () => {
Expand All @@ -139,16 +132,9 @@ function validateProjectWalletAddressTestCases() {

await assertThrowsAsync(async () => {
await validateProjectWalletAddress(
'7Qg4Nj7y6YV1iRQ6jQZn7hLQ7L4r1L7Xb1Y7JZrR9QG', // Last character is changed
undefined,
ChainType.SOLANA,
);
}, errorMessages.INVALID_WALLET_ADDRESS);
await assertThrowsAsync(async () => {
await validateProjectWalletAddress(
generateRandomSolanaAddress(),
SEED_DATA.MALFORMED_SOLANA_ADDRESS,
project.id,
ChainType.EVM,
ChainType.SOLANA,
);
}, errorMessages.INVALID_WALLET_ADDRESS);
});
Expand Down
6 changes: 1 addition & 5 deletions test/graphqlQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const createProjectQuery = `
address
isRecipient
networkId
chainType
}
adminUser{
id
Expand Down Expand Up @@ -117,11 +118,6 @@ export const updateProjectQuery = `
email
walletAddress
}
addresses {
address
isRecipient
networkId
}
}
}
`;
Expand Down

0 comments on commit a3b3833

Please sign in to comment.