@truedat/bg 7.1.3 → 7.1.4

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,172 @@
1
+ import _ from "lodash/fp";
2
+ import React from "react";
3
+ import { render } from "@truedat/test/render";
4
+ import ConceptCrumbs from "../ConceptCrumbs";
5
+
6
+ describe("<ConceptCrumbs />", () => {
7
+ const statuses = [
8
+ "publised",
9
+ "draft",
10
+ "pending_approval",
11
+ "rejected",
12
+ "deprecated",
13
+ ];
14
+
15
+ _.map((status) => {
16
+ const renderOpts = {
17
+ state: {
18
+ concept: {
19
+ name: "foo",
20
+ status: status,
21
+ business_concept_id: 123,
22
+ id: 456,
23
+ i18n_content: {
24
+ es: {
25
+ name: "bar",
26
+ },
27
+ },
28
+ },
29
+ },
30
+ };
31
+
32
+ it(`matches the latest snapshot for status ${status}`, async () => {
33
+ const { container } = render(<ConceptCrumbs />, renderOpts);
34
+ expect(container).toMatchSnapshot();
35
+ });
36
+ })(statuses);
37
+
38
+ it(`matches the latest snapshot for locale`, async () => {
39
+ const renderOpts = {
40
+ locale: "es",
41
+ state: {
42
+ concept: {
43
+ name: "foo",
44
+ status: "deprecated",
45
+ business_concept_id: 123,
46
+ id: 456,
47
+ i18n_content: {
48
+ es: {
49
+ name: "bar",
50
+ },
51
+ },
52
+ },
53
+ },
54
+ };
55
+ const { container } = render(<ConceptCrumbs />, renderOpts);
56
+ expect(container).toMatchSnapshot();
57
+ });
58
+
59
+ it(`matches the latest snapshot for subscope`, async () => {
60
+ const renderOpts = {
61
+ state: {
62
+ concept: {
63
+ name: "foo",
64
+ status: "publised",
65
+ type: "someType",
66
+ business_concept_id: 123,
67
+ id: 456,
68
+ },
69
+ sidemenuGlossarySubscopes: [],
70
+ templates: [{ name: "someType", subscope: "someSubscope" }],
71
+ },
72
+ };
73
+ const { container } = render(<ConceptCrumbs />, renderOpts);
74
+ expect(container).toMatchSnapshot();
75
+ });
76
+
77
+ it(`matches the latest snapshot for subscope in root menu`, async () => {
78
+ const renderOpts = {
79
+ state: {
80
+ concept: {
81
+ name: "foo",
82
+ status: "publised",
83
+ type: "someType",
84
+ business_concept_id: 123,
85
+ id: 456,
86
+ },
87
+ sidemenuGlossarySubscopes: ["someSubscope"],
88
+ templates: [{ name: "someType", subscope: "someSubscope" }],
89
+ },
90
+ };
91
+ const { container } = render(<ConceptCrumbs />, renderOpts);
92
+ expect(container).toMatchSnapshot();
93
+ });
94
+
95
+ it(`matches the latest snapshot for edit`, async () => {
96
+ const renderOpts = {
97
+ state: {
98
+ concept: {
99
+ name: "foo",
100
+ status: "published",
101
+ business_concept_id: 123,
102
+ id: 456,
103
+ },
104
+ },
105
+ };
106
+ const props = {
107
+ conceptAction: "concepts.actions.edit",
108
+ };
109
+ const { container } = render(<ConceptCrumbs {...props} />, renderOpts);
110
+ expect(container).toMatchSnapshot();
111
+ });
112
+
113
+ it(`matches the latest snapshot for edit concept in subscope`, async () => {
114
+ const renderOpts = {
115
+ state: {
116
+ concept: {
117
+ name: "foo",
118
+ status: "published",
119
+ type: "someType",
120
+ business_concept_id: 123,
121
+ id: 456,
122
+ },
123
+ templates: [{ name: "someType", subscope: "someSubscope" }],
124
+ },
125
+ };
126
+ const props = {
127
+ conceptAction: "concepts.actions.edit",
128
+ };
129
+ const { container } = render(<ConceptCrumbs {...props} />, renderOpts);
130
+ expect(container).toMatchSnapshot();
131
+ });
132
+
133
+ it(`matches the latest snapshot for edit concept in subscope in root menu`, async () => {
134
+ const renderOpts = {
135
+ state: {
136
+ concept: {
137
+ name: "foo",
138
+ status: "published",
139
+ type: "someType",
140
+ business_concept_id: 123,
141
+ id: 456,
142
+ },
143
+ sidemenuGlossarySubscopes: ["someSubscope"],
144
+ templates: [{ name: "someType", subscope: "someSubscope" }],
145
+ },
146
+ };
147
+ const props = {
148
+ conceptAction: "concepts.actions.edit",
149
+ };
150
+ const { container } = render(<ConceptCrumbs {...props} />, renderOpts);
151
+ expect(container).toMatchSnapshot();
152
+ });
153
+
154
+ it(`matches the latest snapshot for new concept`, async () => {
155
+ const renderOpts = {
156
+ state: {
157
+ concept: {
158
+ name: null,
159
+ status: null,
160
+ type: null,
161
+ business_concept_id: null,
162
+ id: null,
163
+ },
164
+ },
165
+ };
166
+ const props = {
167
+ conceptAction: "concepts.actions.new",
168
+ };
169
+ const { container } = render(<ConceptCrumbs {...props} />, renderOpts);
170
+ expect(container).toMatchSnapshot();
171
+ });
172
+ });
@@ -0,0 +1,401 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`<ConceptCrumbs /> matches the latest snapshot for edit 1`] = `
4
+ <div>
5
+ <div
6
+ class="ui breadcrumb"
7
+ >
8
+ <a
9
+ class="section"
10
+ href="/concepts"
11
+ >
12
+ Business Glossary
13
+ </a>
14
+ <i
15
+ aria-hidden="true"
16
+ class="right angle icon divider"
17
+ />
18
+ <a
19
+ class="section"
20
+ href="/concepts/123/versions/456"
21
+ >
22
+ foo
23
+ </a>
24
+ <i
25
+ aria-hidden="true"
26
+ class="right angle icon divider"
27
+ />
28
+ <span
29
+ class="active section"
30
+ style="cursor: default;"
31
+ >
32
+ Edit
33
+ </span>
34
+ </div>
35
+ </div>
36
+ `;
37
+
38
+ exports[`<ConceptCrumbs /> matches the latest snapshot for edit concept in subscope 1`] = `
39
+ <div>
40
+ <div
41
+ class="ui breadcrumb"
42
+ >
43
+ <a
44
+ class="section"
45
+ href="/concepts"
46
+ >
47
+ Business Glossary
48
+ </a>
49
+ <i
50
+ aria-hidden="true"
51
+ class="right angle icon divider"
52
+ />
53
+ <a
54
+ class="section"
55
+ href="/concepts/subscope/someSubscope"
56
+ >
57
+ Some Subscope
58
+ </a>
59
+ <i
60
+ aria-hidden="true"
61
+ class="right angle icon divider"
62
+ />
63
+ <a
64
+ class="section"
65
+ href="/concepts/123/versions/456"
66
+ >
67
+ foo
68
+ </a>
69
+ <i
70
+ aria-hidden="true"
71
+ class="right angle icon divider"
72
+ />
73
+ <span
74
+ class="active section"
75
+ style="cursor: default;"
76
+ >
77
+ Edit
78
+ </span>
79
+ </div>
80
+ </div>
81
+ `;
82
+
83
+ exports[`<ConceptCrumbs /> matches the latest snapshot for edit concept in subscope in root menu 1`] = `
84
+ <div>
85
+ <div
86
+ class="ui breadcrumb"
87
+ >
88
+ <a
89
+ class="section"
90
+ href="/glossarySubscope/someSubscope/published"
91
+ >
92
+ Some Subscope
93
+ </a>
94
+ <i
95
+ aria-hidden="true"
96
+ class="right angle icon divider"
97
+ />
98
+ <a
99
+ class="section"
100
+ href="/concepts/123/versions/456"
101
+ >
102
+ foo
103
+ </a>
104
+ <i
105
+ aria-hidden="true"
106
+ class="right angle icon divider"
107
+ />
108
+ <span
109
+ class="active section"
110
+ style="cursor: default;"
111
+ >
112
+ Edit
113
+ </span>
114
+ </div>
115
+ </div>
116
+ `;
117
+
118
+ exports[`<ConceptCrumbs /> matches the latest snapshot for locale 1`] = `
119
+ <div>
120
+ <div
121
+ class="ui breadcrumb"
122
+ >
123
+ <a
124
+ class="section"
125
+ href="/concepts"
126
+ >
127
+ Glosario de conceptos
128
+ </a>
129
+ <i
130
+ aria-hidden="true"
131
+ class="right angle icon divider"
132
+ />
133
+ <a
134
+ class="section"
135
+ href="/concepts/deprecated"
136
+ >
137
+ Archivados
138
+ </a>
139
+ <i
140
+ aria-hidden="true"
141
+ class="right angle icon divider"
142
+ />
143
+ <span
144
+ class="active section"
145
+ style="cursor: default;"
146
+ >
147
+ bar
148
+ </span>
149
+ </div>
150
+ </div>
151
+ `;
152
+
153
+ exports[`<ConceptCrumbs /> matches the latest snapshot for new concept 1`] = `
154
+ <div>
155
+ <div
156
+ class="ui breadcrumb"
157
+ >
158
+ <a
159
+ class="section"
160
+ href="/concepts"
161
+ >
162
+ Business Glossary
163
+ </a>
164
+ <i
165
+ aria-hidden="true"
166
+ class="right angle icon divider"
167
+ />
168
+ <span
169
+ class="active section"
170
+ style="cursor: default;"
171
+ >
172
+ New
173
+ </span>
174
+ </div>
175
+ </div>
176
+ `;
177
+
178
+ exports[`<ConceptCrumbs /> matches the latest snapshot for status deprecated 1`] = `
179
+ <div>
180
+ <div
181
+ class="ui breadcrumb"
182
+ >
183
+ <a
184
+ class="section"
185
+ href="/concepts"
186
+ >
187
+ Business Glossary
188
+ </a>
189
+ <i
190
+ aria-hidden="true"
191
+ class="right angle icon divider"
192
+ />
193
+ <a
194
+ class="section"
195
+ href="/concepts/deprecated"
196
+ >
197
+ Deprecated
198
+ </a>
199
+ <i
200
+ aria-hidden="true"
201
+ class="right angle icon divider"
202
+ />
203
+ <span
204
+ class="active section"
205
+ style="cursor: default;"
206
+ >
207
+ foo
208
+ </span>
209
+ </div>
210
+ </div>
211
+ `;
212
+
213
+ exports[`<ConceptCrumbs /> matches the latest snapshot for status draft 1`] = `
214
+ <div>
215
+ <div
216
+ class="ui breadcrumb"
217
+ >
218
+ <a
219
+ class="section"
220
+ href="/concepts"
221
+ >
222
+ Business Glossary
223
+ </a>
224
+ <i
225
+ aria-hidden="true"
226
+ class="right angle icon divider"
227
+ />
228
+ <a
229
+ class="section"
230
+ href="/concepts/pending"
231
+ >
232
+ Draft
233
+ </a>
234
+ <i
235
+ aria-hidden="true"
236
+ class="right angle icon divider"
237
+ />
238
+ <span
239
+ class="active section"
240
+ style="cursor: default;"
241
+ >
242
+ foo
243
+ </span>
244
+ </div>
245
+ </div>
246
+ `;
247
+
248
+ exports[`<ConceptCrumbs /> matches the latest snapshot for status pending_approval 1`] = `
249
+ <div>
250
+ <div
251
+ class="ui breadcrumb"
252
+ >
253
+ <a
254
+ class="section"
255
+ href="/concepts"
256
+ >
257
+ Business Glossary
258
+ </a>
259
+ <i
260
+ aria-hidden="true"
261
+ class="right angle icon divider"
262
+ />
263
+ <a
264
+ class="section"
265
+ href="/concepts/pending"
266
+ >
267
+ Draft
268
+ </a>
269
+ <i
270
+ aria-hidden="true"
271
+ class="right angle icon divider"
272
+ />
273
+ <span
274
+ class="active section"
275
+ style="cursor: default;"
276
+ >
277
+ foo
278
+ </span>
279
+ </div>
280
+ </div>
281
+ `;
282
+
283
+ exports[`<ConceptCrumbs /> matches the latest snapshot for status publised 1`] = `
284
+ <div>
285
+ <div
286
+ class="ui breadcrumb"
287
+ >
288
+ <a
289
+ class="section"
290
+ href="/concepts"
291
+ >
292
+ Business Glossary
293
+ </a>
294
+ <i
295
+ aria-hidden="true"
296
+ class="right angle icon divider"
297
+ />
298
+ <span
299
+ class="active section"
300
+ style="cursor: default;"
301
+ >
302
+ foo
303
+ </span>
304
+ </div>
305
+ </div>
306
+ `;
307
+
308
+ exports[`<ConceptCrumbs /> matches the latest snapshot for status rejected 1`] = `
309
+ <div>
310
+ <div
311
+ class="ui breadcrumb"
312
+ >
313
+ <a
314
+ class="section"
315
+ href="/concepts"
316
+ >
317
+ Business Glossary
318
+ </a>
319
+ <i
320
+ aria-hidden="true"
321
+ class="right angle icon divider"
322
+ />
323
+ <a
324
+ class="section"
325
+ href="/concepts/pending"
326
+ >
327
+ Draft
328
+ </a>
329
+ <i
330
+ aria-hidden="true"
331
+ class="right angle icon divider"
332
+ />
333
+ <span
334
+ class="active section"
335
+ style="cursor: default;"
336
+ >
337
+ foo
338
+ </span>
339
+ </div>
340
+ </div>
341
+ `;
342
+
343
+ exports[`<ConceptCrumbs /> matches the latest snapshot for subscope 1`] = `
344
+ <div>
345
+ <div
346
+ class="ui breadcrumb"
347
+ >
348
+ <a
349
+ class="section"
350
+ href="/concepts"
351
+ >
352
+ Business Glossary
353
+ </a>
354
+ <i
355
+ aria-hidden="true"
356
+ class="right angle icon divider"
357
+ />
358
+ <a
359
+ class="section"
360
+ href="/concepts/subscope/someSubscope"
361
+ >
362
+ Some Subscope
363
+ </a>
364
+ <i
365
+ aria-hidden="true"
366
+ class="right angle icon divider"
367
+ />
368
+ <span
369
+ class="active section"
370
+ style="cursor: default;"
371
+ >
372
+ foo
373
+ </span>
374
+ </div>
375
+ </div>
376
+ `;
377
+
378
+ exports[`<ConceptCrumbs /> matches the latest snapshot for subscope in root menu 1`] = `
379
+ <div>
380
+ <div
381
+ class="ui breadcrumb"
382
+ >
383
+ <a
384
+ class="section"
385
+ href="/glossarySubscope/someSubscope/published"
386
+ >
387
+ Some Subscope
388
+ </a>
389
+ <i
390
+ aria-hidden="true"
391
+ class="right angle icon divider"
392
+ />
393
+ <span
394
+ class="active section"
395
+ style="cursor: default;"
396
+ >
397
+ foo
398
+ </span>
399
+ </div>
400
+ </div>
401
+ `;
@@ -0,0 +1,37 @@
1
+ import { getConceptSubscope } from "../getConceptSubscope";
2
+
3
+ describe("getConceptSubscope", () => {
4
+ it("returns the subscope string if concept type matches a template", () => {
5
+ const state = {
6
+ concept: { id: 123, type: "someType" },
7
+ templates: [{ name: "someType", subscope: "someSubscope" }],
8
+ };
9
+ const result = getConceptSubscope(state);
10
+ expect(result).toBe("someSubscope");
11
+ });
12
+
13
+ it("returns null if concept exists but no template matches its type", () => {
14
+ const state = {
15
+ concept: { id: 123, type: "otherType" },
16
+ templates: [{ name: "someType", subscope: "someSubscope" }],
17
+ };
18
+ const result = getConceptSubscope(state);
19
+ expect(result).toBeNull();
20
+ });
21
+
22
+ it("returns undefined if concept is missing or has no id", () => {
23
+ const stateA = {
24
+ concept: undefined, // No concept at all
25
+ templates: [{ name: "someType", subscope: "someSubscope" }],
26
+ };
27
+ const resultA = getConceptSubscope(stateA);
28
+ expect(resultA).toBeUndefined();
29
+
30
+ const stateB = {
31
+ concept: {}, // Concept object but no id
32
+ templates: [{ name: "someType", subscope: "someSubscope" }],
33
+ };
34
+ const resultB = getConceptSubscope(stateB);
35
+ expect(resultB).toBeUndefined();
36
+ });
37
+ });