@explorer02/cfm-survey-sdk 0.0.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=questionMapper.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"questionMapper.test.d.ts","sourceRoot":"","sources":["../../../../src/fetchSurvey/utils/mappers/questionMapper.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ const questionMapper_1 = require("./questionMapper");
5
+ (0, vitest_1.describe)('questionMapper translation logic', () => {
6
+ const mockApiQuestion = {
7
+ id: 'q1',
8
+ answerType: 'RATING',
9
+ questionText: 'How are you?',
10
+ translations: {
11
+ fr: {
12
+ questionText: 'Comment allez-vous?'
13
+ }
14
+ },
15
+ answerDetails: [
16
+ {
17
+ answerText: '0',
18
+ translations: {
19
+ fr: { answerText: 'Zéro' }
20
+ }
21
+ },
22
+ {
23
+ answerText: '10',
24
+ translations: {
25
+ fr: { answerText: 'Dix' }
26
+ }
27
+ },
28
+ // Hint text
29
+ {
30
+ answerText: 'Very Bad',
31
+ additional: { isHintText: true },
32
+ translations: { fr: { answerText: 'Très Mal' } }
33
+ },
34
+ {
35
+ answerText: 'Very Good',
36
+ additional: { isHintText: true },
37
+ translations: { fr: { answerText: 'Très Bien' } }
38
+ }
39
+ ],
40
+ questionConfigs: [
41
+ {
42
+ key: 'REQUIRED_ERROR_MESSAGE',
43
+ value: ['This field is required'],
44
+ translations: {
45
+ fr: {
46
+ value: ['Ce champ est obligatoire']
47
+ }
48
+ }
49
+ }
50
+ ]
51
+ };
52
+ (0, vitest_1.it)('returns base language text when no language is passed', () => {
53
+ const question = (0, questionMapper_1.mapQuestion)(mockApiQuestion);
54
+ // Base question text
55
+ (0, vitest_1.expect)(question.text).toBe('How are you?');
56
+ // Base options
57
+ (0, vitest_1.expect)(question.options[0].label).toBe('0');
58
+ (0, vitest_1.expect)(question.options[1].label).toBe('10');
59
+ // Base hints
60
+ (0, vitest_1.expect)(question.minLabel).toBe('Very Bad');
61
+ (0, vitest_1.expect)(question.maxLabel).toBe('Very Good');
62
+ // Base error message
63
+ (0, vitest_1.expect)(question.requiredErrorMessage).toBe('This field is required');
64
+ });
65
+ (0, vitest_1.it)('returns translated text when a specific language is passed', () => {
66
+ const question = (0, questionMapper_1.mapQuestion)(mockApiQuestion, 'fr');
67
+ // Translated question text
68
+ (0, vitest_1.expect)(question.text).toBe('Comment allez-vous?');
69
+ // Translated options
70
+ (0, vitest_1.expect)(question.options[0].label).toBe('Zéro');
71
+ (0, vitest_1.expect)(question.options[1].label).toBe('Dix');
72
+ // Translated hints
73
+ (0, vitest_1.expect)(question.minLabel).toBe('Très Mal');
74
+ (0, vitest_1.expect)(question.maxLabel).toBe('Très Bien');
75
+ // Translated error message
76
+ (0, vitest_1.expect)(question.requiredErrorMessage).toBe('Ce champ est obligatoire');
77
+ });
78
+ });
79
+ //# sourceMappingURL=questionMapper.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"questionMapper.test.js","sourceRoot":"","sources":["../../../../src/fetchSurvey/utils/mappers/questionMapper.test.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAC9C,qDAA+C;AAG/C,IAAA,iBAAQ,EAAC,kCAAkC,EAAE,GAAG,EAAE;IAChD,MAAM,eAAe,GAAgB;QACnC,EAAE,EAAE,IAAI;QACR,UAAU,EAAE,QAAQ;QACpB,YAAY,EAAE,cAAc;QAC5B,YAAY,EAAE;YACZ,EAAE,EAAE;gBACF,YAAY,EAAE,qBAAqB;aACpC;SACF;QACD,aAAa,EAAE;YACb;gBACE,UAAU,EAAE,GAAG;gBACf,YAAY,EAAE;oBACZ,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE;iBAC3B;aACF;YACD;gBACE,UAAU,EAAE,IAAI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AAI,CAAC,WAAW,CAAC,CAAC;QAE5C,qBAAqB;QACrB,IAAA,eAAM,EAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,MAAM,QAAQ,GAAG,IAAA,4BAAW,EAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QAEpD,2BAA2B;QAC3B,IAAA,eAAM,EAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAElD,qBAAqB;QACrB,IAAA,eAAM,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/C,IAAA,eAAM,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAE9C,mBAAmB;QACnB,IAAA,eAAM,EAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC3C,IAAA,eAAM,EAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAE5C,2BAA2B;QAC3B,IAAA,eAAM,EAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@explorer02/cfm-survey-sdk",
3
- "version": "0.0.9",
3
+ "version": "0.1.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "bin": {
@@ -15,15 +15,21 @@
15
15
  "build": "tsc",
16
16
  "lint": "tsc --noEmit",
17
17
  "prepare": "yarn build",
18
- "postinstall": "node postinstall.js"
18
+ "postinstall": "node postinstall.js",
19
+ "test": "vitest run",
20
+ "test:watch": "vitest"
19
21
  },
20
22
  "peerDependencies": {
21
- "react": "^17.0.0 || ^18.0.0 || ^19.0.0"
23
+ "react": ">=17.0.0"
22
24
  },
23
25
  "devDependencies": {
26
+ "@testing-library/jest-dom": "^6.4.2",
27
+ "@testing-library/react": "^14.2.1",
28
+ "@testing-library/user-event": "^14.5.2",
24
29
  "@types/react": "^19.1.6",
25
30
  "@tanstack/react-query": "^5.0.0",
26
- "react": "^19.1.0",
27
- "typescript": "^5.8.3"
31
+ "jsdom": "^24.0.0",
32
+ "typescript": "^5.8.3",
33
+ "vitest": "^1.3.1"
28
34
  }
29
35
  }