Skip to content

Commit

Permalink
Merge branch 'develop' into feat/selectOrgOnRegistration
Browse files Browse the repository at this point in the history
  • Loading branch information
AVtheking authored Apr 4, 2024
2 parents 9d4a8e0 + 1faccc7 commit b9b4304
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 110 deletions.
126 changes: 63 additions & 63 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,75 @@
"prettier"
],
"overrides": [
{
"files": ["*.ts"], // Specify that the following rules apply only to TypeScript files
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"tsconfigRootDir": ".",
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
// Typescript additional rules
"@typescript-eslint/array-type": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/explicit-function-return-type": "error",

// Interfaces must begin with Interface or TestInterface followed by a PascalCase name
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "interface",
"format": ["PascalCase"],
"prefix": ["Interface", "TestInterface"]
},
{
"selector": ["typeAlias", "typeLike", "enum"],
"format": ["PascalCase"]
},
{
"selector": "typeParameter",
"format": ["PascalCase"],
"prefix": ["T"]
},
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE"],
"leadingUnderscore": "allow"
},
{
"selector": "parameter",
"format": ["camelCase"],
"leadingUnderscore": "allow"
},
{
"selector": "function",
"format": ["camelCase"]
},
{
"selector": "memberLike",
"modifiers": ["private"],
"format": ["camelCase"],
"leadingUnderscore": "require"
},
{
"selector": "variable",
"modifiers": ["exported"],
"format": null
}
]
}
},
{
"files": ["./src/typeDefs/**/*.ts"],
"processor": "@graphql-eslint/graphql"
},
{
"files": ["./src/typeDefs/**/*.graphql"],
"parser": "@graphql-eslint/eslint-plugin",
"plugins": ["@graphql-eslint"],
// Do not apply naming conventions to .graphql files
"rules": {
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/consistent-type-assertions": "off"
}
"plugins": ["@graphql-eslint"]
},
{
"files": ["tests/**/*"],
Expand All @@ -39,14 +95,7 @@
}
}
],

"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"tsconfigRootDir": ".",
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "eslint-plugin-tsdoc", "import"],
"root": true,
"rules": {
Expand All @@ -56,7 +105,6 @@
"patterns": ["**/src/**"]
}
],

// restrict the use of same package in multiple import statements
"import/no-duplicates": "error",

Expand All @@ -70,54 +118,6 @@
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-var-requires": "error",

// Typescript rule to enforce PascalCase naming convention for types and interfaces
"@typescript-eslint/naming-convention": [
"error",
// Interfaces must begin with Interface or TestInterface followed by a PascalCase name
{
"selector": "interface",
"format": ["PascalCase"],
"prefix": ["Interface", "TestInterface"]
},
// Type Aliases must be in PascalCase
{
"selector": ["typeAlias", "typeLike", "enum"],
"format": ["PascalCase"]
},
{
"selector": "typeParameter",
"format": ["PascalCase"],
"prefix": ["T"]
},
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE"],
"leadingUnderscore": "allow"
},
{
"selector": "parameter",
"format": ["camelCase"],
"leadingUnderscore": "allow"
},
{
"selector": "function",
"format": ["camelCase"]
},
{
"selector": "memberLike",
"modifiers": ["private"],
"format": ["camelCase"],
"leadingUnderscore": "require"
},
{ "selector": "variable", "modifiers": ["exported"], "format": null }
],

// Typescript additional rules
"@typescript-eslint/array-type": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/explicit-function-return-type": "error"
"@typescript-eslint/no-var-requires": "error"
}
}
88 changes: 44 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@
"@types/nodemailer": "^6.4.14",
"@types/uuid": "^9.0.7",
"@types/validator": "^13.11.9",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/parser": "^7.5.0",
"@vitest/coverage-v8": "^1.4.0",
"cls-bluebird": "^2.1.0",
"concurrently": "^8.2.2",
Expand Down
2 changes: 1 addition & 1 deletion tests/resolvers/Mutation/recaptcha.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { recaptcha as recaptchaResolver } from "../../../src/resolvers/Mutation/
import { describe, it, expect } from "vitest";

describe("resolvers -> Mutation -> recaptcha", () => {
it("should not generate recaptcha with a dummy recaptcha token", async () => {
it("should not generate recaptcha with a dummy recaptcha token ", async () => {
const args: MutationRecaptchaArgs = {
data: {
recaptchaToken: "dummyToken",
Expand Down
33 changes: 33 additions & 0 deletions tests/resolvers/Mutation/removeUserFamily.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type {
TestUserType,
} from "../../helpers/userAndUserFamily";
import { createTestUserFunc } from "../../helpers/userAndUserFamily";
import { AppUserProfile } from "../../../src/models";

let MONGOOSE_INSTANCE: typeof mongoose;
let testUsers: TestUserType[];
Expand Down Expand Up @@ -136,4 +137,36 @@ describe("resolvers -> Mutation -> removeUserFamily", () => {
);
}
});

it("throws user not found error if current user profile is not found", async () => {
const { requestContext } = await import("../../../src/libraries");
const spy = vi
.spyOn(requestContext, "translate")
.mockImplementation((message) => message);

try {
const args: MutationRemoveUserFamilyArgs = {
familyId: testUserFamily?.id,
};

await AppUserProfile.deleteOne({
userId: testUsers[0]?.id,
});

const context = {
userId: testUsers[0]?.id,
};

const { removeUserFamily: removeUserFamilyResolver } = await import(
"../../../src/resolvers/Mutation/removeUserFamily"
);

await removeUserFamilyResolver?.({}, args, context);
} catch (error) {
expect(spy).toHaveBeenCalledWith(USER_NOT_FOUND_ERROR.MESSAGE);
expect((error as Error).message).toEqual(
`${USER_NOT_FOUND_ERROR.MESSAGE}`,
);
}
});
});

0 comments on commit b9b4304

Please sign in to comment.