@socialgouv/kali-data-types 2.257.0 → 2.259.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socialgouv/kali-data-types",
3
- "version": "2.257.0",
3
+ "version": "2.259.1",
4
4
  "devDependencies": {
5
5
  "@babel/core": "^7.16.0",
6
6
  "@babel/plugin-transform-modules-commonjs": "^7.16.0",
@@ -8,6 +8,11 @@ describe(`libs/getAgreementArticlesWithPath()`, () => {
8
8
  expect(received[0].path.length).toBeGreaterThan(1);
9
9
  });
10
10
 
11
+ it("with an existing agreement ID (empty children)", () => {
12
+ const received = getAgreementArticlesWithPath("KALICONT000005635259");
13
+ expect(received).toHaveLength(0);
14
+ });
15
+
11
16
  it(`with an existing agreement IDCC (string)`, () => {
12
17
  const received = getAgreementArticlesWithPath("1480");
13
18
 
@@ -20,12 +20,14 @@ function getAgreementArticlesWithPath(agreementIdOrIdcc) {
20
20
  /** @type {{ children: KaliData.AgreementArticle[], type: "root" }} */
21
21
  (/** @type {*} */ (unistUtilFlatFilter(agreement, { type: "article" })));
22
22
 
23
- const articlesWithPath = rootedArticles.children.map(article => ({
23
+ if (!rootedArticles) {
24
+ return [];
25
+ }
26
+
27
+ return rootedArticles.children.map(article => ({
24
28
  ...article,
25
29
  path: getIndexedArticle(article.data.cid).path,
26
30
  }));
27
-
28
- return articlesWithPath;
29
31
  }
30
32
 
31
33
  module.exports = getAgreementArticlesWithPath;