-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Correction de la fonction de formattage de numéro de téléphone +…
… tests (#151)
- Loading branch information
Showing
2 changed files
with
35 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { describe, expect, test } from "vitest"; | ||
import { formatPhoneNumber } from "$lib/utils/misc"; | ||
|
||
describe("formatPhoneNumber", () => { | ||
test("formate correctement un numéro de téléphone avec des espaces", () => { | ||
expect(formatPhoneNumber("06 12 34 56 78")).toBe("06 12 34 56 78"); | ||
}); | ||
|
||
test("supprime les espaces supplémentaires et formate correctement", () => { | ||
expect(formatPhoneNumber("06 12 34 56 78")).toBe("06 12 34 56 78"); | ||
}); | ||
|
||
test("gère un numéro sans espaces", () => { | ||
expect(formatPhoneNumber("0612345678")).toBe("06 12 34 56 78"); | ||
}); | ||
|
||
test("gère un numéro avec un nombre impair de chiffres", () => { | ||
expect(formatPhoneNumber("06123456789")).toBe("06 12 34 56 78 9"); | ||
}); | ||
|
||
test("retourne une chaîne vide pour une entrée vide", () => { | ||
expect(formatPhoneNumber("")).toBe(""); | ||
}); | ||
|
||
test("ignore les caractères non numériques", () => { | ||
expect(formatPhoneNumber("06a12b34c56d78")).toBe("06 12 34 56 78"); | ||
}); | ||
}); |