Skip to content

Commit

Permalink
better code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lakshz committed Feb 13, 2024
1 parent 0cda201 commit 72def40
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 40 deletions.
33 changes: 1 addition & 32 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1123,8 +1123,8 @@ input UserInput {
email: EmailAddress!
firstName: String!
lastName: String!
organizationUserBelongsToId: ID
password: String!
selectedOrgainzation: ID!
}

enum UserOrderByInput {
Expand Down Expand Up @@ -1182,37 +1182,6 @@ type UserTagsConnectionResult {
errors: [ConnectionError!]!
}

type UserToReturn {
_id: ID!
address: Address
adminApproved: Boolean
adminFor: [Organization]
appLanguageCode: String!
birthDate: Date
createdAt: DateTime!
createdEvents: [Event]
createdOrganizations: [Organization]
educationGrade: EducationGrade
email: EmailAddress!
employmentStatus: EmploymentStatus
eventAdmin: [Event]
firstName: String!
gender: Gender
image: String
joinedOrganizations: [Organization]
lastName: String!
maritalStatus: MaritalStatus
membershipRequests: [MembershipRequest]
organizationsBlockedBy: [Organization]
phone: UserPhone
pluginCreationAllowed: Boolean!
registeredEvents: [Event]
tagsAssignedWith(after: String, before: String, first: PositiveInt, last: PositiveInt, organizationId: ID): UserTagsConnection
tokenVersion: Int!
updatedAt: DateTime!
userType: UserType!
}

enum UserType {
ADMIN
NON_USER
Expand Down
18 changes: 10 additions & 8 deletions tests/utilities/encodedImageStorage/uploadEncodedImage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,22 @@ describe("src -> utilities -> encodedImageStorage -> uploadEncodedImage", () =>
"NAAAAKElEQVQ4jWNgYGD4Twzu6FhFFGYYNXDUwGFpIAk2E4dHDRw1cDgaCAASFOffhEIO" +
"3gAAAABJRU5ErkJggg==";
await uploadEncodedImage(img, null);
} catch (error: any) {
expect(error.message).toEqual(`Translated ${INVALID_FILE_TYPE.MESSAGE}`);
} catch (error: unknown) {
expect((error as Error).message).toEqual(
`Translated ${INVALID_FILE_TYPE.MESSAGE}`
);

expect(spy).toBeCalledWith(INVALID_FILE_TYPE.MESSAGE);
}
});

it("should not create new image if it is bigger than the limit", async () => {
const size = Number(process.env.IMAGE_SIZE_LIMIT_KB);
const size = Number(process.env.IMAGE_SIZE_LIMIT_KB) || 3000;
try {
const img = "data:image/jpg;base64," + generateRandomString(size + 1000);
await uploadEncodedImage(img, null);
} catch (error: any) {
expect(error.message).toEqual(IMAGE_SIZE_LIMIT_KB.MESSAGE);
} catch (error: unknown) {
expect((error as Error).message).toEqual(IMAGE_SIZE_LIMIT_KB.MESSAGE);
}
});

Expand All @@ -71,7 +73,7 @@ describe("src -> utilities -> encodedImageStorage -> uploadEncodedImage", () =>
"3gAAAABJRU5ErkJggg==";
const fileName = await uploadEncodedImage(img, null);
expect(fileName).not.toBe(null);
} catch (error: any) {
} catch (error: unknown) {
console.log(error);
}
});
Expand All @@ -85,7 +87,7 @@ describe("src -> utilities -> encodedImageStorage -> uploadEncodedImage", () =>
const fileName = await uploadEncodedImage(img, null);
expect(fileName).not.toBe(null);
testPreviousImagePath = fileName;
} catch (error: any) {
} catch (error: unknown) {
console.log(error);
}
});
Expand Down Expand Up @@ -180,7 +182,7 @@ describe("src -> utilities -> encodedImageStorage -> uploadEncodedImage", () =>
fs.unlink(path.join(__dirname, "../../../".concat(fileName)), (err) => {
if (err) throw err;
});
} catch (error: any) {
} catch (error: unknown) {
console.log(error);
}
});
Expand Down

0 comments on commit 72def40

Please sign in to comment.