@legalplace/tagextractor 2.1.0 → 2.3.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.
package/jest.config.ts ADDED
@@ -0,0 +1,205 @@
1
+ /*
2
+ * For a detailed explanation regarding each configuration property and type check, visit:
3
+ * https://jestjs.io/docs/configuration
4
+ */
5
+
6
+ const jestConfig = {
7
+ // All imported modules in your tests should be mocked automatically
8
+ // automock: false,
9
+
10
+ // Stop running tests after `n` failures
11
+ // bail: 0,
12
+
13
+ // The directory where Jest should store its cached dependency information
14
+ // cacheDirectory: "/private/var/folders/cc/yjms5nz10198m80g1mz2zy980000gn/T/jest_dx",
15
+
16
+ // Automatically clear mock calls and instances between every test
17
+ clearMocks: true,
18
+
19
+ // Indicates whether the coverage information should be collected while executing the test
20
+ collectCoverage: false,
21
+
22
+ // An array of glob patterns indicating a set of files for which coverage information should be collected
23
+ collectCoverageFrom: [
24
+ "src/**/*.ts",
25
+ "src/**/*.tsx",
26
+ "!**/node_modules/**",
27
+ "!src/**/*.d.ts",
28
+ ],
29
+
30
+ // The directory where Jest should output its coverage files
31
+ coverageDirectory: "./coverage",
32
+
33
+ // An array of regexp pattern strings used to skip coverage collection
34
+ // coveragePathIgnorePatterns: ['/node_modules/', '/dist/'],
35
+
36
+ // Indicates which provider should be used to instrument code for coverage
37
+ coverageProvider: "v8",
38
+
39
+ // A list of reporter names that Jest uses when writing coverage reports
40
+ coverageReporters: ["html", "text", "text-summary", "cobertura"],
41
+
42
+ // An object that configures minimum threshold enforcement for coverage results
43
+ // coverageThreshold: {
44
+ // global: {
45
+ // branches: 77,
46
+ // functions: 100,
47
+ // lines: 84,
48
+ // statements: 84,
49
+ // },
50
+ // },
51
+
52
+ // A path to a custom dependency extractor
53
+ // dependencyExtractor: undefined,
54
+
55
+ // Make calling deprecated APIs throw helpful error messages
56
+ // errorOnDeprecated: false,
57
+
58
+ // Force coverage collection from ignored files using an array of glob patterns
59
+ // forceCoverageMatch: [],
60
+
61
+ // A path to a module which exports an async function that is triggered once before all test suites
62
+ // globalSetup: undefined,
63
+
64
+ // A path to a module which exports an async function that is triggered once after all test suites
65
+ // globalTeardown: undefined,
66
+
67
+ // A set of global variables that need to be available in all test environments
68
+ // globals: {},
69
+
70
+ // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
71
+ // maxWorkers: "50%",
72
+
73
+ // An array of directory names to be searched recursively up from the requiring module's location
74
+ // moduleDirectories: [
75
+ // "node_modules"
76
+ // ],
77
+
78
+ // An array of file extensions your modules use
79
+ // moduleFileExtensions: [
80
+ // "js",
81
+ // "jsx",
82
+ // "ts",
83
+ // "tsx",
84
+ // "json",
85
+ // "node"
86
+ // ],
87
+
88
+ // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
89
+ moduleNameMapper: {
90
+ "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
91
+ "<rootDir>__mocks__/fileMock.js",
92
+ "\\.(css|less|sass|scss)$": "identity-obj-proxy",
93
+ },
94
+
95
+ // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
96
+ // modulePathIgnorePatterns: [],
97
+
98
+ // Activates notifications for test results
99
+ // notify: false,
100
+
101
+ // An enum that specifies notification mode. Requires { notify: true }
102
+ // notifyMode: "failure-change",
103
+
104
+ // A preset that is used as a base for Jest's configuration
105
+ // preset: undefined,
106
+
107
+ // Run tests from one or more projects
108
+ // projects: undefined,
109
+
110
+ // Use this configuration option to add custom reporters to Jest
111
+ // reporters: undefined,
112
+
113
+ // Automatically reset mock state between every test
114
+ // resetMocks: false,
115
+
116
+ // Reset the module registry before running each individual test
117
+ // resetModules: false,
118
+
119
+ // A path to a custom resolver
120
+ // resolver: undefined,
121
+
122
+ // Automatically restore mock state between every test
123
+ // restoreMocks: false,
124
+
125
+ // The root directory that Jest should scan for tests and modules within
126
+ // rootDir: undefined,
127
+
128
+ // A list of paths to directories that Jest should use to search for files in
129
+ roots: ["src/"],
130
+
131
+ // Allows you to use a custom runner instead of Jest's default test runner
132
+ // runner: "jest-runner",
133
+
134
+ // The paths to modules that run some code to configure or set up the testing environment before each test
135
+ setupFiles: ["./setupJest.ts"],
136
+
137
+ // A list of paths to modules that run some code to configure or set up the testing framework before each test
138
+ // setupFilesAfterEnv: [],
139
+
140
+ // The number of seconds after which a test is considered as slow and reported as such in the results.
141
+ // slowTestThreshold: 5,
142
+
143
+ // A list of paths to snapshot serializer modules Jest should use for snapshot testing
144
+ // snapshotSerializers: [],
145
+
146
+ // The test environment that will be used for testing
147
+ testEnvironment: "jsdom",
148
+
149
+ // Options that will be passed to the testEnvironment
150
+ // testEnvironmentOptions: {},
151
+
152
+ // Adds a location field to test results
153
+ // testLocationInResults: false,
154
+
155
+ // The glob patterns Jest uses to detect test files
156
+ // testMatch: [
157
+ // "**/__tests__/**/*.[jt]s?(x)",
158
+ // "**/?(*.)+(spec|test).[tj]s?(x)"
159
+ // ],
160
+
161
+ // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
162
+ // testPathIgnorePatterns: [
163
+ // "/node_modules/"
164
+ // ],
165
+
166
+ // The regexp pattern or array of patterns that Jest uses to detect test files
167
+ // testRegex: [],
168
+
169
+ // This option allows the use of a custom results processor
170
+ // testResultsProcessor: undefined,
171
+
172
+ // This option allows use of a custom test runner
173
+ // testRunner: "jest-circus/runner",
174
+
175
+ // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
176
+ // testURL: "http://localhost",
177
+
178
+ // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
179
+ // timers: "real",
180
+
181
+ // A map from regular expressions to paths to transformers
182
+ transform: {
183
+ "^.+\\.tsx?$": "@swc-node/jest",
184
+ },
185
+
186
+ // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
187
+ // transformIgnorePatterns: [
188
+ // "/node_modules/",
189
+ // "\\.pnp\\.[^\\/]+$"
190
+ // ],
191
+
192
+ // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
193
+ // unmockedModulePathPatterns: undefined,
194
+
195
+ // Indicates whether each individual test should be reported during the run
196
+ // verbose: undefined,
197
+
198
+ // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
199
+ // watchPathIgnorePatterns: [],
200
+
201
+ // Whether to use watchman for file crawling
202
+ // watchman: true,
203
+ };
204
+
205
+ export default jestConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/tagextractor",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "description": "TagExtractor",
5
5
  "main": "dist/index.js",
6
6
  "repository": "https://git.legalplace.eu/legalplace/tagextractor",
@@ -10,34 +10,37 @@
10
10
  "format": "prettier --single-quote --no-semi --trailing-comma none --write \"src/**/*.{js,ts,tsx}\"",
11
11
  "lint": "tsc && eslint ./src/ --ext ts,js",
12
12
  "lint:fix": "tsc && eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
13
- "test": "jest",
14
- "build": "tsc"
13
+ "build": "tsc",
14
+ "test": "jest --watchAll",
15
+ "test:ci": "jest --config ./jest.config.ts --collectCoverage --coverageDirectory=\"./coverage\" --ci --reporters=default --reporters=jest-junit --watchAll=false",
16
+ "test:coverage": "jest test --coverage --watchAll=false "
15
17
  },
16
18
  "dependencies": {
17
19
  "@legalplace/conditions-runner": "1.1.1",
18
20
  "@legalplace/lplogic": "2.1.6",
19
21
  "@legalplace/models-v3-types": "3.4.47",
20
22
  "@legalplace/ovc-converter": "1.1.0",
21
- "@legalplace/referencesparser": "1.6.3",
22
- "typescript": "3.9.3"
23
+ "@legalplace/referencesparser": "1.6.3"
23
24
  },
24
25
  "devDependencies": {
25
- "@babel/core": "^7.7.2",
26
- "@babel/preset-typescript": "^7.7.2",
26
+ "@legalplace/eslint-config": "^2.1.3",
27
+ "@legalplace/prettier-config": "^2.1.3",
27
28
  "@legalplace/types": "1.1.0",
28
- "@types/jest": "^24.0.15",
29
- "@types/node": "^12.12.6",
30
- "@typescript-eslint/eslint-plugin": "^2.6.1",
31
- "@typescript-eslint/parser": "^2.6.1",
32
- "airbnb-standard": "^1.0.0",
33
- "eslint": "^6.6.0",
34
- "eslint-config-airbnb-base": "^14.0.0",
35
- "eslint-config-prettier": "^6.5.0",
36
- "eslint-plugin-import": "^2.18.2",
37
- "eslint-plugin-prettier": "^3.1.1",
38
- "jest": "^24.8.0",
39
- "prettier": "1.19.1",
40
- "redux-mock-store": "^1.5.3",
41
- "ts-jest": "^24.0.2"
42
- }
29
+ "@swc-node/jest": "^1.4.3",
30
+ "@types/jest": "27.4.0",
31
+ "@typescript-eslint/eslint-plugin": "^5.8.0",
32
+ "eslint": "^8.5.0",
33
+ "eslint-config-airbnb": "^19.0.2",
34
+ "eslint-config-prettier": "^8.3.0",
35
+ "eslint-config-react-app": "^7.0.0",
36
+ "jest": "27.4.7",
37
+ "jest-fetch-mock": "^3.0.3",
38
+ "jest-junit": "^13.0.0",
39
+ "prettier": "^2.5.1",
40
+ "ts-jest": "27.1.2",
41
+ "ts-node": "^10.4.0",
42
+ "typescript": "4.5.2"
43
+ },
44
+ "prettier": "@legalplace/prettier-config",
45
+ "gitHead": "b78de6625e6f2651aeb2bdb470ae4dfc6e4a8487"
43
46
  }
package/setupJest.ts ADDED
@@ -0,0 +1,8 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
2
+ import { GlobalWithFetchMock } from "jest-fetch-mock";
3
+
4
+ const customGlobal: GlobalWithFetchMock =
5
+ global as unknown as GlobalWithFetchMock;
6
+ customGlobal.fetch = require("jest-fetch-mock");
7
+
8
+ customGlobal.fetchMock = customGlobal.fetch;
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- import TagExtractor from './libs/Extractor'
1
+ import TagExtractor from "./libs/Extractor";
2
2
 
3
- import TagsType, { OptionTagType, VariableTagType } from './types/tags.type'
3
+ import TagsType, { OptionTagType, VariableTagType } from "./types/tags.type";
4
4
 
5
- export { TagsType, OptionTagType, VariableTagType }
6
- export default TagExtractor
5
+ export type { TagsType, OptionTagType, VariableTagType };
6
+ export default TagExtractor;
@@ -0,0 +1,360 @@
1
+ import { ReferencesType } from "@legalplace/referencesparser/dist/libs/References.type";
2
+ import InputsType from "@legalplace/types/dist/inputs";
3
+ import OvcType from "@legalplace/types/dist/ovc";
4
+ import { ModelV3 } from "@legalplace/models-v3-types";
5
+ import TagExtractor from "./Extractor";
6
+ import ovcJson from "./fixtures/ovc.json";
7
+ import inputsJson from "./fixtures/inputs.json";
8
+ import referencesJson from "./fixtures/references.json";
9
+ import modelJson from "./fixtures/model.json";
10
+
11
+ const simpleReferences = referencesJson as unknown as ReferencesType;
12
+ const simpleModel = modelJson as unknown as ModelV3;
13
+ const simpleOvc = ovcJson as unknown as OvcType;
14
+ const simpleInputs = inputsJson as unknown as InputsType;
15
+
16
+ describe("TagsExtractor", () => {
17
+ const tagExtractor = new TagExtractor(simpleReferences, simpleInputs);
18
+
19
+ afterEach(() => {
20
+ jest.clearAllMocks();
21
+ jest.restoreAllMocks();
22
+ });
23
+
24
+ describe("IsVariableDisplayed", () => {
25
+ it("should return false when variable condition is false", () => {
26
+ const getVariableCondition = jest.spyOn(
27
+ TagExtractor.prototype as any,
28
+ "getVariableCondition"
29
+ );
30
+ getVariableCondition.mockImplementation(() => false);
31
+
32
+ expect(tagExtractor.isVariableDisplayed(1, 0)).toBeFalsy();
33
+ expect(getVariableCondition).toHaveBeenCalledWith(1, 0);
34
+ });
35
+ it("should return false when parent Option is not displayed", () => {
36
+ const isOptionDisplayed = jest.spyOn(
37
+ TagExtractor.prototype as any,
38
+ "isOptionDisplayed"
39
+ );
40
+ isOptionDisplayed.mockImplementation(() => false);
41
+
42
+ expect(tagExtractor.isVariableDisplayed(1, 0)).toBeFalsy();
43
+ expect(isOptionDisplayed).toHaveBeenCalledWith(6, 0);
44
+ });
45
+ it("should return false when parent Option is not truthful", () => {
46
+ const inputsWithParentsFalse = {
47
+ ...simpleInputs,
48
+ options: { ...simpleInputs.options, "6": [false] },
49
+ };
50
+ const customTagExtractor = new TagExtractor(
51
+ simpleReferences,
52
+ inputsWithParentsFalse
53
+ );
54
+ expect(customTagExtractor.isVariableDisplayed(1, 0)).toBeFalsy();
55
+ });
56
+ it("should return true when all checks are okay", () => {
57
+ const inputsWithAllChecks = {
58
+ ...simpleInputs,
59
+ options: { ...simpleInputs.options, "8": [true] },
60
+ };
61
+ const customTagExtractor = new TagExtractor(
62
+ simpleReferences,
63
+ inputsWithAllChecks
64
+ );
65
+
66
+ expect(customTagExtractor.isVariableDisplayed(1, 0)).toBeTruthy();
67
+ });
68
+ });
69
+ describe("IsOptionDisplayed", () => {
70
+ it("should return false when option condition is false", () => {
71
+ const getOptionCondition = jest.spyOn(
72
+ TagExtractor.prototype as any,
73
+ "getOptionCondition"
74
+ );
75
+ getOptionCondition.mockImplementation(
76
+ (id, index) => !(id === 24 && index === 0)
77
+ );
78
+
79
+ expect(tagExtractor.isOptionDisplayed(24, 0)).toBeFalsy();
80
+ expect(getOptionCondition).toHaveBeenCalledWith(24, 0);
81
+ });
82
+ it("should return false when parentSectionCondition is false", () => {
83
+ const getSectionCondition = jest.spyOn(
84
+ TagExtractor.prototype as any,
85
+ "getSectionCondition"
86
+ );
87
+ getSectionCondition.mockImplementation(() => false);
88
+
89
+ expect(tagExtractor.isOptionDisplayed(24, 0)).toBeFalsy();
90
+ expect(getSectionCondition).toHaveBeenCalledWith(1);
91
+ });
92
+ it("should return false when parentCondition contains false value", () => {
93
+ const getOptionCondition = jest.spyOn(
94
+ TagExtractor.prototype as any,
95
+ "getOptionCondition"
96
+ );
97
+ getOptionCondition.mockImplementation(
98
+ (id, index) => !(id === 6 && index === 0)
99
+ );
100
+
101
+ expect(tagExtractor.isOptionDisplayed(24, 0)).toBeFalsy();
102
+ expect(getOptionCondition).toHaveBeenCalledWith(24, 0);
103
+ });
104
+ it("should return false when parentsInputs list contains false value", () => {
105
+ const inputsWithParentsInputsFalse = {
106
+ ...simpleInputs,
107
+ options: { ...simpleInputs.options, "6": [false] },
108
+ };
109
+ const customTagExtractor = new TagExtractor(
110
+ simpleReferences,
111
+ inputsWithParentsInputsFalse
112
+ );
113
+
114
+ expect(customTagExtractor.isOptionDisplayed(24, 0)).toBeFalsy();
115
+ });
116
+ it("should not return errors when parentsInputs is undefined", () => {
117
+ const inputsWithParentsInputsUndefined = {
118
+ ...simpleInputs,
119
+ options: { ...simpleInputs.options },
120
+ };
121
+ delete inputsWithParentsInputsUndefined.options["6"];
122
+ const customTagExtractor = new TagExtractor(
123
+ simpleReferences,
124
+ inputsWithParentsInputsUndefined
125
+ );
126
+
127
+ expect(customTagExtractor.isOptionDisplayed(24, 0)).toBeFalsy();
128
+ });
129
+ it("should return true when all checks are okay", () => {
130
+ expect(tagExtractor.isOptionDisplayed(24, 0)).toBeTruthy();
131
+ });
132
+ });
133
+ describe("convertToOptionVariables", () => {
134
+ it("should tag extraction match when instanciating TagExtractor with ovc or inputs", () => {
135
+ const customTagExtractor = new TagExtractor(simpleReferences, simpleOvc);
136
+ const expectedTags = new TagExtractor(simpleReferences, simpleInputs)
137
+ .getTags;
138
+
139
+ expect(customTagExtractor.getTags).toMatchObject(expectedTags);
140
+ });
141
+ });
142
+ describe("ReferenceParser", () => {
143
+ it("should tag extraction match when instanciating TagExtractor with model or references", () => {
144
+ const customTagExtractor = new TagExtractor(simpleModel, simpleInputs);
145
+ const expectedTags = new TagExtractor(simpleReferences, simpleInputs)
146
+ .getTags;
147
+
148
+ expect(customTagExtractor.getTags).toMatchObject(expectedTags);
149
+ });
150
+ });
151
+ describe("extractFromOptions", () => {
152
+ it("should return empty tag object when tags are undefined", () => {
153
+ const referencesWithoutOptionTagArray = {
154
+ ...simpleReferences,
155
+ options: {
156
+ ...simpleReferences.options,
157
+ "7": {
158
+ ...simpleReferences.options["7"],
159
+ meta: { ...simpleReferences.options["7"].meta, tags: undefined },
160
+ },
161
+ },
162
+ };
163
+ const customTagExtractor = new TagExtractor(
164
+ referencesWithoutOptionTagArray,
165
+ simpleInputs
166
+ );
167
+
168
+ expect(customTagExtractor.getTags.options).toMatchObject({});
169
+ });
170
+ it("should return empty tag object when options tags are empty", () => {
171
+ const referencesWithoutOptionTags = {
172
+ ...simpleReferences,
173
+ options: {
174
+ ...simpleReferences.options,
175
+ "7": {
176
+ ...simpleReferences.options["7"],
177
+ meta: { ...simpleReferences.options["7"].meta, tags: [] },
178
+ },
179
+ },
180
+ };
181
+ const customTagExtractor = new TagExtractor(
182
+ referencesWithoutOptionTags,
183
+ simpleInputs
184
+ );
185
+
186
+ expect(customTagExtractor.getTags.options).toMatchObject({});
187
+ });
188
+ it("should return empty tags when input's option is undefined", () => {
189
+ const inputsWithoutOptionTaggedAnswer = {
190
+ ...simpleInputs,
191
+ options: { ...simpleInputs.options },
192
+ };
193
+ delete inputsWithoutOptionTaggedAnswer.options["7"];
194
+ const customTagExtractor = new TagExtractor(
195
+ simpleReferences,
196
+ inputsWithoutOptionTaggedAnswer
197
+ );
198
+
199
+ expect(customTagExtractor.getTags.options).toMatchObject({});
200
+ });
201
+ it("should return option tag when champ multiples", () => {
202
+ const inputWithChampMultiple = {
203
+ ...simpleInputs,
204
+ options: { ...simpleInputs.options, "7": [true, false] },
205
+ };
206
+ const customTagExtractor = new TagExtractor(
207
+ simpleReferences,
208
+ inputWithChampMultiple
209
+ );
210
+ const expectedOptionTags = {
211
+ LP_fan: [
212
+ {
213
+ id: 7,
214
+ index: 0,
215
+ label: "Connaissiez-vous déjà LegalPlace ?",
216
+ condition: true,
217
+ visible: true,
218
+ value: true,
219
+ },
220
+ {
221
+ id: 7,
222
+ index: 1,
223
+ label: "Connaissiez-vous déjà LegalPlace ?",
224
+ condition: true,
225
+ visible: true,
226
+ value: false,
227
+ },
228
+ ],
229
+ };
230
+ expect(customTagExtractor.getTags.options).toMatchObject(
231
+ expectedOptionTags
232
+ );
233
+ });
234
+ it("should return option tags", () => {
235
+ const expectedOptionTags = {
236
+ LP_fan: [
237
+ {
238
+ id: 7,
239
+ index: 0,
240
+ label: "Connaissiez-vous déjà LegalPlace ?",
241
+ condition: true,
242
+ visible: true,
243
+ value: true,
244
+ },
245
+ ],
246
+ };
247
+ expect(tagExtractor.getTags.options).toMatchObject(expectedOptionTags);
248
+ });
249
+ });
250
+ describe("extractFromVariables", () => {
251
+ it("should return empty tag object when tags are undefined", () => {
252
+ const referenceWithoutVariableTagArray = {
253
+ ...simpleReferences,
254
+ variables: {
255
+ ...simpleReferences.variables,
256
+ "1": { ...simpleReferences.variables["1"], tags: undefined },
257
+ },
258
+ };
259
+ const customTagExtractor = new TagExtractor(
260
+ referenceWithoutVariableTagArray,
261
+ simpleInputs
262
+ );
263
+
264
+ expect(customTagExtractor.getTags.variables).toMatchObject({});
265
+ });
266
+ it("should return empty tag object when variables tags are empty", () => {
267
+ const referenceWithoutTags = {
268
+ ...simpleReferences,
269
+ variables: {
270
+ ...simpleReferences.variables,
271
+ "1": { ...simpleReferences.variables["1"], tags: [] },
272
+ },
273
+ };
274
+ const customTagExtractor = new TagExtractor(
275
+ referenceWithoutTags,
276
+ simpleInputs
277
+ );
278
+
279
+ expect(customTagExtractor.getTags.variables).toMatchObject({});
280
+ });
281
+ it("should return empty tags when input's variable is undefined", () => {
282
+ const inputsWithoutVariableTaggedAnswer = {
283
+ ...simpleInputs,
284
+ variables: { ...simpleInputs.variables },
285
+ };
286
+ delete inputsWithoutVariableTaggedAnswer.variables[1];
287
+ const customTagExtractor = new TagExtractor(
288
+ simpleReferences,
289
+ inputsWithoutVariableTaggedAnswer
290
+ );
291
+
292
+ expect(customTagExtractor.getTags.variables).toMatchObject({});
293
+ });
294
+ it("should not throw error when input's variable does not match any references variable", () => {
295
+ const referenceWithoutMatchingVariable = {
296
+ ...simpleReferences,
297
+ variables: { ...simpleReferences.variables },
298
+ };
299
+ delete referenceWithoutMatchingVariable.variables["2"];
300
+
301
+ const customTagExtractor = new TagExtractor(
302
+ referenceWithoutMatchingVariable,
303
+ simpleInputs
304
+ );
305
+ const expectedVariableTags = {
306
+ Company_name: [
307
+ {
308
+ id: 1,
309
+ index: 0,
310
+ label: "Nom de l'entreprise",
311
+ condition: false,
312
+ visible: false,
313
+ value: "Company",
314
+ },
315
+ ],
316
+ };
317
+
318
+ expect(customTagExtractor.getTags.variables).toMatchObject(
319
+ expectedVariableTags
320
+ );
321
+ });
322
+ it("should return variable tag when champ multiples", () => {
323
+ const inputVariableWithChampMultiple = {
324
+ ...simpleInputs,
325
+ variables: {
326
+ ...simpleInputs.variables,
327
+ "1": ["Nom de la companie", "Testing Company"],
328
+ },
329
+ };
330
+ const customTagExtractor = new TagExtractor(
331
+ simpleReferences,
332
+ inputVariableWithChampMultiple
333
+ );
334
+ const expectedVariableTags = {
335
+ Company_name: [
336
+ {
337
+ id: 1,
338
+ index: 0,
339
+ label: "Nom de l'entreprise",
340
+ condition: false,
341
+ visible: false,
342
+ value: "Nom de la companie",
343
+ },
344
+ {
345
+ id: 1,
346
+ index: 1,
347
+ label: "Nom de l'entreprise",
348
+ condition: false,
349
+ visible: false,
350
+ value: "Testing Company",
351
+ },
352
+ ],
353
+ };
354
+
355
+ expect(customTagExtractor.getTags.variables).toMatchObject(
356
+ expectedVariableTags
357
+ );
358
+ });
359
+ });
360
+ });