feat: add async suffix eslint rule (#485)

This commit is contained in:
Manuel
2024-05-18 12:25:33 +02:00
committed by GitHub
parent 5723295856
commit dcaff1d91c
60 changed files with 296 additions and 225 deletions

View File

@@ -18,7 +18,7 @@ import * as definitions from "@homarr/definitions";
import {
createSessionCallback,
createSignInCallback,
getCurrentUserPermissions,
getCurrentUserPermissionsAsync,
} from "../callbacks";
describe("getCurrentUserPermissions", () => {
@@ -30,7 +30,7 @@ describe("getCurrentUserPermissions", () => {
});
const userId = "1";
const result = await getCurrentUserPermissions(db, userId);
const result = await getCurrentUserPermissionsAsync(db, userId);
expect(result).toEqual([]);
});
test("should return permissions for user", async () => {
@@ -56,7 +56,7 @@ describe("getCurrentUserPermissions", () => {
permission: "admin",
});
const result = await getCurrentUserPermissions(db, mockId);
const result = await getCurrentUserPermissionsAsync(db, mockId);
expect(result).toEqual(["board-create"]);
expect(getPermissionsWithChildrenMock).toHaveBeenCalledWith(["admin"]);
});

View File

@@ -1,16 +1,16 @@
import { describe, expect, it } from "vitest";
import { createSalt, hashPassword } from "../security";
import { createSaltAsync, hashPasswordAsync } from "../security";
describe("createSalt should return a salt", () => {
it("should return a salt", async () => {
const result = await createSalt();
const result = await createSaltAsync();
expect(result).toBeDefined();
expect(result.length).toBeGreaterThan(25);
});
it("should return a different salt each time", async () => {
const result1 = await createSalt();
const result2 = await createSalt();
const result1 = await createSaltAsync();
const result2 = await createSaltAsync();
expect(result1).not.toEqual(result2);
});
});
@@ -18,8 +18,8 @@ describe("createSalt should return a salt", () => {
describe("hashPassword should return a hash", () => {
it("should return a hash", async () => {
const password = "password";
const salt = await createSalt();
const result = await hashPassword(password, salt);
const salt = await createSaltAsync();
const result = await hashPasswordAsync(password, salt);
expect(result).toBeDefined();
expect(result.length).toBeGreaterThan(55);
expect(result).not.toEqual(password);
@@ -27,20 +27,20 @@ describe("hashPassword should return a hash", () => {
it("should return a different hash each time", async () => {
const password = "password";
const password2 = "another password";
const salt = await createSalt();
const salt = await createSaltAsync();
const result1 = await hashPassword(password, salt);
const result2 = await hashPassword(password2, salt);
const result1 = await hashPasswordAsync(password, salt);
const result2 = await hashPasswordAsync(password2, salt);
expect(result1).not.toEqual(result2);
});
it("should return a different hash for the same password with different salts", async () => {
const password = "password";
const salt1 = await createSalt();
const salt2 = await createSalt();
const salt1 = await createSaltAsync();
const salt2 = await createSaltAsync();
const result1 = await hashPassword(password, salt1);
const result2 = await hashPassword(password, salt2);
const result1 = await hashPasswordAsync(password, salt1);
const result2 = await hashPasswordAsync(password, salt2);
expect(result1).not.toEqual(result2);
});