-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ajout du tracker pour l'annulation de la prise de contact (#147)
* test: rajouter des tests unitaires sur la nouvelles versions des trackers + les anciennes fonctionnalités * feat: ajout du tracker pour l'annulation de la prise de contact * fix: test coverage remove duplicate code * fix: sonar properties exlude test file * fix: duplicate line * fix: duplicate line
- Loading branch information
1 parent
c33bebf
commit 227b36d
Showing
8 changed files
with
121 additions
and
23 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
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,75 @@ | ||
import { STORAGE_CONTACT_TYPE } from "../../src/constants/constants" | ||
import * as TrackerUtils from "../../src/utils/tracker.utils" | ||
|
||
describe("Trackers utils", () => { | ||
describe("Should return tracker for every category", () => { | ||
let trackerSpy | ||
|
||
beforeEach(() => { | ||
trackerSpy = jest.spyOn(TrackerUtils, "track") | ||
}) | ||
|
||
test("Should return tracker with demographic category", () => { | ||
TrackerUtils.track( | ||
TrackerUtils.CATEG.demography, | ||
TrackerUtils.ACTION.end_demo | ||
) | ||
expect(trackerSpy).toHaveBeenCalledWith( | ||
"Démographie", | ||
"Terminer le formulaire démographique" | ||
) | ||
}) | ||
test("Should return tracker with survey category", () => { | ||
TrackerUtils.track( | ||
TrackerUtils.CATEG.survey, | ||
TrackerUtils.ACTION.end_survey | ||
) | ||
expect(trackerSpy).toHaveBeenCalledWith( | ||
"Questionnaire", | ||
"Terminer le questionnaire" | ||
) | ||
}) | ||
test("Should return tracker with results category", () => { | ||
const score = 11 | ||
TrackerUtils.track( | ||
TrackerUtils.CATEG.results, | ||
TrackerUtils.seuilScore(score) | ||
) | ||
expect(trackerSpy).toHaveBeenCalledWith("Résultat", "score >= 11") | ||
}) | ||
test("Should return tracker with intentions category", () => { | ||
TrackerUtils.track( | ||
TrackerUtils.CATEG.intentions, | ||
TrackerUtils.ACTION.download | ||
) | ||
expect(trackerSpy).toHaveBeenCalledWith( | ||
"Intentions", | ||
"Télécharger mes réponses" | ||
) | ||
}) | ||
test("Should return tracker with contacts category", () => { | ||
localStorage.setItem(STORAGE_CONTACT_TYPE, "sms") | ||
const typeContact = localStorage.getItem(STORAGE_CONTACT_TYPE) | ||
TrackerUtils.track(TrackerUtils.CATEG.contact, `Choix ${typeContact}`) | ||
expect(trackerSpy).toHaveBeenCalledWith("Contact", "Choix sms") | ||
}) | ||
}) | ||
describe("Should return good value for seuil score", () => { | ||
test("Should return score < 9 if score from EPDS is <9", () => { | ||
const score = 4 | ||
const score2 = 9 | ||
expect(TrackerUtils.seuilScore(score)).toEqual("score < 9") | ||
expect(TrackerUtils.seuilScore(score2)).toEqual("9 >= score < 11") | ||
}) | ||
test("Should return 9 >= score < 11 if score from EPDS is between 9 & 11", () => { | ||
const score = 9 | ||
const score2 = 11 | ||
expect(TrackerUtils.seuilScore(score)).toEqual("9 >= score < 11") | ||
expect(TrackerUtils.seuilScore(score2)).toEqual("score >= 11") | ||
}) | ||
test("Should return score >= 11 if score from EPDS is >11", () => { | ||
const score = 26 | ||
expect(TrackerUtils.seuilScore(score)).toEqual("score >= 11") | ||
}) | ||
}) | ||
}) |
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
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