Skip to content

Commit

Permalink
refactor: from mocha chai to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Feb 18, 2025
1 parent 0b1017d commit be7a3a7
Show file tree
Hide file tree
Showing 71 changed files with 83 additions and 21 deletions.
2 changes: 2 additions & 0 deletions cypress/e2e/activate_totp/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { generateToken } from "@sunknudsen/totp";

import { describe, it } from "vitest";

describe("add 2fa authentication", () => {
it("should add 2fa authentication on account user", function () {
cy.visit("/connection-and-account");
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/check_email_deliverability/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
describe("should suggest valid email address", () => {
it("should sign-in", function () {
cy.visit("http://localhost:4001");
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/delete_account/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

describe("delete account", () => {
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/delete_totp/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
describe("delete TOTP connexion", () => {
it("should delete TOTP application", function () {
cy.visit("/connection-and-account");
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/join_and_moderation/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

describe("join organizations", () => {
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/join_must_confirm/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

describe("join organizations", () => {
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/join_org_with_trackdechets_domain/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

//
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/join_org_with_verified_domain/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

describe("join organizations", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

describe("join organizations", () => {
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/join_with_official_contact_email/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

describe("join organizations", () => {
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/reauthenticate_on_admin_page/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
describe("force recent connexion + 2FA on admin pages", () => {
it("should be redirected after long connexion", function () {
cy.visit("/");
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/redirect_after_session_expiration/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
describe("redirect after session expiration", () => {
it("should be redirected to organization management page", function () {
cy.visit("/manage-organizations");
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/reset_password/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

describe("sign-in with magic link", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

describe("set info after account provisioning", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeEach, describe, it } from "vitest";
//

describe("sign-in from proconnect federation client", () => {
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/signin_from_standard_client/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

describe("sign-in from standard client", () => {
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/signin_with_email_verification/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

describe("sign-in with email verification renewal", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

describe("sign-in with email verification renewal", () => {
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/signin_with_legacy_scope/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

describe("sign-in with legacy scope", () => {
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/signin_with_magic_link/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

describe("sign-in with magic link", () => {
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/signin_with_right_acr/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeEach, describe, it } from "vitest";
describe("sign-in with a client not requiring any acr", () => {
beforeEach(() => {
cy.visit("http://localhost:4000");
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/signin_with_totp/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
describe("sign-in with TOTP on untrusted browser", () => {
it("should sign-in with password and TOTP", function () {
cy.visit("http://localhost:4000");
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/signup_entreprise_unipersonnelle/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
//

describe("Signup into new entreprise unipersonnelle", () => {
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/update_personal_information/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from "vitest";
describe("Signup into new entreprise unipersonnelle", () => {
it("Should send email when user updates personal information", function () {
cy.visit("/personal-information");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//

import { assert } from "chai";
import { describe, it } from "mocha";
import { describe, it } from "vitest";
import { GenerarateDicewarePassword } from "./generate-diceware-password.js";

//
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/security/generate-pin-token.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//

import { assert } from "chai";
import { describe, it } from "mocha";
import { describe, it } from "vitest";
import { generatePinToken } from "./generate-pin-token.js";

//
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/security/generate-token.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//

import { assert } from "chai";
import { describe, it } from "vitest";
import { generateToken } from "./generate-token.js";

//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//

import { assert } from "chai";
import { describe, it } from "mocha";
import { describe, it } from "vitest";
import { getTrustedReferrerPath } from "./get-trusted-referrer-path.js";

//
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/security/hash-password.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import bcrypt from "bcryptjs";
import { assert } from "chai";
import { describe, it } from "vitest";
import { hashPassword } from "./hash-password.js";

//
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/security/is-domain-valid.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//

import { assert } from "chai";
import { describe, it } from "vitest";
import { isDomainValid } from "./is-domain-valid.js";

//
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/security/is-email-valid.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { assert } from "chai";
import { describe, it } from "vitest";
import { isEmailValid } from "./is-email-valid.js";

describe("isEmailValid", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/security/is-name-valid.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//

import { assert } from "chai";
import { describe, it } from "mocha";
import { describe, it } from "vitest";
import { isNameValid } from "./is-name-valid.js";

//
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/security/is-password-secure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// heavily inspired from https://github.com/nowsecure/owasp-password-strength-test/blob/1.3.0/test.js

import { assert } from "chai";
import { describe, it } from "vitest";
import { isPasswordSecure } from "./is-password-secure.js";

//
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/security/is-phone-number-valid.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//

import { assert } from "chai";
import { describe, it } from "mocha";
import { describe, it } from "vitest";
import { isPhoneNumberValid } from "./is-phone-number-valid.js";

//
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/security/is-siret-valid.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//

import { assert } from "chai";
import { describe, it } from "mocha";
import { describe, it } from "vitest";
import { isSiretValid } from "./is-siret-valid.js";

//
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/security/is-visible-string.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//

import { assert } from "chai";
import { describe, it } from "mocha";
import { describe, it } from "vitest";
import { isVisibleString } from "./is-visible-string.js";

describe("isVisibleString", () => {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/security/validate-password.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import bcrypt from "bcryptjs";
import { assert } from "chai";
import { describe, it } from "vitest";
import { validatePassword } from "./validate-password.js";

//
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/services/email/get-email-domain.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//

import { assert } from "chai";
import { describe, it } from "vitest";
import { getEmailDomain } from "./get-email-domain.js";

//
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/services/suggestion/did-you-mean.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { assert } from "chai";
import { describe, it } from "vitest";
import { getDidYouMeanSuggestion } from "./did-you-mean.js";

describe("getDidYouMeanSuggestion", () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/debounce/src/api/single-validation.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//

import { expect } from "chai";
import { before, describe } from "mocha";
import { before } from "mocha";
import { describe, it } from "vitest";
import { singleValidationFactory } from "./single-validation.js";

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { InseeEtablissement } from "@gouvfr-lasuite/proconnect.insee/types"
import * as chai from "chai";
import chaiAsPromised from "chai-as-promised";
import nock from "nock";
import { beforeEach, describe, it } from "vitest";
import diffusible from "./__mocks__/diffusible.json" with { type: "json" };
import partiallyNonDiffusible from "./__mocks__/partially-non-diffusible.json" with { type: "json" };
import searchBySiren from "./__mocks__/search-by-siren.json" with { type: "json" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type {
import * as chai from "chai";
import chaiAsPromised from "chai-as-promised";
import { mock } from "node:test";
import { describe, it } from "vitest";
import { markDomainAsVerifiedFactory } from "./mark-domain-as-verified.js";
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { emptyDatabase, migrate, pg } from "#testing";
import { expect } from "chai";
import { before, describe, it } from "mocha";
import { before } from "mocha";
import { beforeEach, describe, it } from "vitest";
import { addDomainFactory } from "./add-domain.js";

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { emptyDatabase, migrate, pg } from "#testing";
import { expect } from "chai";
import { before, describe, it } from "mocha";
import { before } from "mocha";
import { beforeEach, describe, it } from "vitest";
import { findEmailDomainsByOrganizationIdFactory } from "./find-email-domains-by-organization-id.js";

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { emptyDatabase, migrate, pg } from "#testing";
import { expect } from "chai";
import { before, describe, it } from "mocha";
import { before } from "mocha";
import { beforeEach, describe, it } from "vitest";
import { findByIdFactory } from "./find-by-id.js";

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { emptyDatabase, migrate, pg } from "#testing";
import { expect } from "chai";
import { before, describe, it } from "mocha";
import { before } from "mocha";
import { beforeEach, describe, it } from "vitest";
import { getUsersByOrganizationFactory } from "./get-users-by-organization.js";

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { emptyDatabase, migrate, pg } from "#testing";
import { expect } from "chai";
import { before, describe, it } from "mocha";
import { before } from "mocha";
import { beforeEach, describe, it } from "vitest";
import { upsertFactory } from "./upsert.js";

//
Expand Down
3 changes: 2 additions & 1 deletion packages/identite/src/repositories/user/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { emptyDatabase, migrate, pg } from "#testing";
import { expect } from "chai";
import { before, describe, it } from "mocha";
import { before } from "mocha";
import { beforeEach, describe, it } from "vitest";
import { createUserFactory } from "./create.js";

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { emptyDatabase, migrate, pg } from "#testing";
import { expect } from "chai";
import { before, describe, it } from "mocha";
import { before } from "mocha";
import { beforeEach, describe, it } from "vitest";
import { findByEmailFactory } from "./find-by-email.js";

//
Expand Down
3 changes: 2 additions & 1 deletion packages/identite/src/repositories/user/find-by-id.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { emptyDatabase, migrate, pg } from "#testing";
import { expect } from "chai";
import { before, describe, it } from "mocha";
import { before } from "mocha";
import { beforeEach, describe, it } from "vitest";
import { findByIdFactory } from "./find-by-id.js";

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { emptyDatabase, migrate, pg } from "#testing";
import { expect } from "chai";
import { before, describe, it } from "mocha";
import { before } from "mocha";
import { beforeEach, describe, it } from "vitest";
import { updateUserOrganizationLinkFactory } from "./update-user-organization-link.js";

//
Expand Down
3 changes: 2 additions & 1 deletion packages/identite/src/repositories/user/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { emptyDatabase, migrate, pg } from "#testing";
import { expect } from "chai";
import { before, describe, it } from "mocha";
import { before } from "mocha";
import { beforeEach, describe, it } from "vitest";
import { updateUserFactory } from "./update.js";

//
Expand Down
2 changes: 1 addition & 1 deletion packages/insee/src/api/find-by-siren.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//

import { expect } from "chai";
import { describe, it } from "mocha";
import nock from "nock";
import { describe, it } from "vitest";
import { findBySirenFactory } from "./find-by-siren.js";

//
Expand Down
Loading

0 comments on commit be7a3a7

Please sign in to comment.