@socialgouv/kali-data 2.614.0 → 2.616.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.
Files changed (34) hide show
  1. package/data/KALICONT000005635472.json +0 -1
  2. package/data/KALICONT000005635624.json +6 -6
  3. package/data/KALICONT000005635905.json +0 -1
  4. package/data/index.json +14 -42
  5. package/package.json +78 -77
  6. package/src/__tests__/index.test.js +15 -15
  7. package/src/helpers/__tests__/checkArticleIdOrCid.test.js +8 -8
  8. package/src/helpers/__tests__/isFile.test.js +14 -14
  9. package/src/helpers/checkArticleIdOrCid.js +6 -6
  10. package/src/helpers/isFile.js +1 -1
  11. package/src/helpers/withArticleIdOrCid.js +2 -2
  12. package/src/index.js +11 -11
  13. package/src/libs/__tests__/getAgreement.test.js +28 -28
  14. package/src/libs/__tests__/getAgreementArticlesWithParentSections.test.js +13 -13
  15. package/src/libs/__tests__/getAgreementArticlesWithPath.test.js +13 -13
  16. package/src/libs/__tests__/getAgreementIdFromIdOrIdcc.test.js +17 -17
  17. package/src/libs/__tests__/getAgreements.test.js +3 -3
  18. package/src/libs/__tests__/getArticleWithParentSections.test.js +19 -19
  19. package/src/libs/__tests__/getArticleWithPath.test.js +19 -19
  20. package/src/libs/__tests__/getArticles.test.js +3 -3
  21. package/src/libs/__tests__/getIndexedArticle.test.js +19 -19
  22. package/src/libs/__tests__/hasAgreement.test.js +23 -23
  23. package/src/libs/__tests__/hasArticle.test.js +14 -14
  24. package/src/libs/getAgreement.js +7 -7
  25. package/src/libs/getAgreementArticlesWithParentSections.js +22 -22
  26. package/src/libs/getAgreementArticlesWithPath.js +11 -11
  27. package/src/libs/getAgreementIdFromIdOrIdcc.js +18 -18
  28. package/src/libs/getAgreements.js +3 -3
  29. package/src/libs/getArticleWithParentSections.js +34 -34
  30. package/src/libs/getArticleWithPath.js +25 -25
  31. package/src/libs/getArticles.js +3 -3
  32. package/src/libs/getIndexedArticle.js +6 -6
  33. package/src/libs/hasAgreement.js +10 -9
  34. package/src/libs/hasArticle.js +6 -6
@@ -6,12 +6,12 @@
6
6
  * @returns {void}
7
7
  */
8
8
  function checkArticleIdOrCid(articleIdOrCid) {
9
- if (typeof articleIdOrCid !== "string" || !/^KALIARTI\d{12}$/.test(articleIdOrCid)) {
10
- throw new Error(
11
- `<articleIdOrCid> is malformed (${articleIdOrCid}). ` +
12
- `It must be a valid article ID or CID (string: "KALIARTI123456789012").`,
13
- );
14
- }
9
+ if (typeof articleIdOrCid !== "string" || !/^KALIARTI\d{12}$/.test(articleIdOrCid)) {
10
+ throw new Error(
11
+ `<articleIdOrCid> is malformed (${articleIdOrCid}). ` +
12
+ `It must be a valid article ID or CID (string: "KALIARTI123456789012").`,
13
+ );
14
+ }
15
15
  }
16
16
 
17
17
  module.exports = checkArticleIdOrCid;
@@ -8,7 +8,7 @@ const fs = require("fs");
8
8
  * @returns {boolean}
9
9
  */
10
10
  function isFile(absolutePath) {
11
- return fs.existsSync(absolutePath) && fs.lstatSync(absolutePath).isFile();
11
+ return fs.existsSync(absolutePath) && fs.lstatSync(absolutePath).isFile();
12
12
  }
13
13
 
14
14
  module.exports = isFile;
@@ -4,8 +4,8 @@
4
4
  * @returns {((indexedArticle: KaliData.IndexedArticle) => boolean)}
5
5
  */
6
6
  function withArticleIdOrCid(articleIdOrCid) {
7
- return indexedArticle =>
8
- indexedArticle.articleId === articleIdOrCid || indexedArticle.articleCid === articleIdOrCid;
7
+ return indexedArticle =>
8
+ indexedArticle.articleId === articleIdOrCid || indexedArticle.articleCid === articleIdOrCid;
9
9
  }
10
10
 
11
11
  module.exports = withArticleIdOrCid;
package/src/index.js CHANGED
@@ -13,15 +13,15 @@ const hasAgreement = require("./libs/hasAgreement");
13
13
  const hasArticle = require("./libs/hasArticle");
14
14
 
15
15
  module.exports = {
16
- getAgreement,
17
- getAgreementArticlesWithParentSections,
18
- getAgreementArticlesWithPath,
19
- getAgreementIdFromIdOrIdcc,
20
- getAgreements,
21
- getArticleWithParentSections,
22
- getArticleWithPath,
23
- getArticles,
24
- getIndexedArticle,
25
- hasAgreement,
26
- hasArticle,
16
+ getAgreement,
17
+ getAgreementArticlesWithParentSections,
18
+ getAgreementArticlesWithPath,
19
+ getAgreementIdFromIdOrIdcc,
20
+ getAgreements,
21
+ getArticleWithParentSections,
22
+ getArticleWithPath,
23
+ getArticles,
24
+ getIndexedArticle,
25
+ hasAgreement,
26
+ hasArticle,
27
27
  };
@@ -1,39 +1,39 @@
1
1
  import getAgreement from "../getAgreement";
2
2
 
3
3
  describe(`libs/getAgreement()`, () => {
4
- describe(`should match properties`, () => {
5
- it(`with an existing agreement ID`, () => {
6
- const received = getAgreement("KALICONT000005635444");
4
+ describe(`should match properties`, () => {
5
+ it(`with an existing agreement ID`, () => {
6
+ const received = getAgreement("KALICONT000005635444");
7
7
 
8
- expect(received.data.id).toBe("KALICONT000005635444");
9
- expect(received.data.num).toBe(1480);
10
- });
11
-
12
- it(`with an existing agreement IDCC (string)`, () => {
13
- const received = getAgreement("1480");
8
+ expect(received.data.id).toBe("KALICONT000005635444");
9
+ expect(received.data.num).toBe(1480);
10
+ });
14
11
 
15
- expect(received.data.id).toBe("KALICONT000005635444");
16
- expect(received.data.num).toBe(1480);
17
- });
12
+ it(`with an existing agreement IDCC (string)`, () => {
13
+ const received = getAgreement("1480");
18
14
 
19
- it(`with an existing agreement IDCC (number)`, () => {
20
- const received = getAgreement(1480);
15
+ expect(received.data.id).toBe("KALICONT000005635444");
16
+ expect(received.data.num).toBe(1480);
17
+ });
21
18
 
22
- expect(received.data.id).toBe("KALICONT000005635444");
23
- expect(received.data.num).toBe(1480);
24
- });
25
- });
26
- describe(`should throw`, () => {
27
- it(`with a nonexistent agreement ID`, () => {
28
- expect(() => getAgreement("KALICONT123456789012")).toThrow();
29
- });
19
+ it(`with an existing agreement IDCC (number)`, () => {
20
+ const received = getAgreement(1480);
30
21
 
31
- it(`with a nonexistent agreement IDCC (string)`, () => {
32
- expect(() => getAgreement("1234")).toThrow();
22
+ expect(received.data.id).toBe("KALICONT000005635444");
23
+ expect(received.data.num).toBe(1480);
24
+ });
33
25
  });
34
-
35
- it(`with a nonexistent agreement IDCC (number)`, () => {
36
- expect(() => getAgreement(1234)).toThrow();
26
+ describe(`should throw`, () => {
27
+ it(`with a nonexistent agreement ID`, () => {
28
+ expect(() => getAgreement("KALICONT123456789012")).toThrow();
29
+ });
30
+
31
+ it(`with a nonexistent agreement IDCC (string)`, () => {
32
+ expect(() => getAgreement("1234")).toThrow();
33
+ });
34
+
35
+ it(`with a nonexistent agreement IDCC (number)`, () => {
36
+ expect(() => getAgreement(1234)).toThrow();
37
+ });
37
38
  });
38
- });
39
39
  });
@@ -1,23 +1,23 @@
1
1
  import getAgreementArticlesWithParentSections from "../getAgreementArticlesWithParentSections";
2
2
 
3
3
  describe(`libs/getAgreementArticlesWithParentSections()`, () => {
4
- describe(`should match snapshot`, () => {
5
- it(`with an existing agreement ID`, () => {
6
- const received = getAgreementArticlesWithParentSections("KALICONT000005635221");
4
+ describe(`should match snapshot`, () => {
5
+ it(`with an existing agreement ID`, () => {
6
+ const received = getAgreementArticlesWithParentSections("KALICONT000005635221");
7
7
 
8
- expect(received[0].sections.length).toBeGreaterThan(1);
9
- });
8
+ expect(received[0].sections.length).toBeGreaterThan(1);
9
+ });
10
10
 
11
- it(`with an existing agreement IDCC (string)`, () => {
12
- const received = getAgreementArticlesWithParentSections("1480");
11
+ it(`with an existing agreement IDCC (string)`, () => {
12
+ const received = getAgreementArticlesWithParentSections("1480");
13
13
 
14
- expect(received[0].sections.length).toBeGreaterThan(1);
15
- });
14
+ expect(received[0].sections.length).toBeGreaterThan(1);
15
+ });
16
16
 
17
- it(`with an existing agreement IDCC (number)`, () => {
18
- const received = getAgreementArticlesWithParentSections(1480);
17
+ it(`with an existing agreement IDCC (number)`, () => {
18
+ const received = getAgreementArticlesWithParentSections(1480);
19
19
 
20
- expect(received[0].sections.length).toBeGreaterThan(1);
20
+ expect(received[0].sections.length).toBeGreaterThan(1);
21
+ });
21
22
  });
22
- });
23
23
  });
@@ -1,23 +1,23 @@
1
1
  import getAgreementArticlesWithPath from "../getAgreementArticlesWithPath";
2
2
 
3
3
  describe(`libs/getAgreementArticlesWithPath()`, () => {
4
- describe(`should match snapshot`, () => {
5
- it(`with an existing agreement ID`, () => {
6
- const received = getAgreementArticlesWithPath("KALICONT000005635221");
4
+ describe(`should match snapshot`, () => {
5
+ it(`with an existing agreement ID`, () => {
6
+ const received = getAgreementArticlesWithPath("KALICONT000005635221");
7
7
 
8
- expect(received[0].path.length).toBeGreaterThan(1);
9
- });
8
+ expect(received[0].path.length).toBeGreaterThan(1);
9
+ });
10
10
 
11
- it(`with an existing agreement IDCC (string)`, () => {
12
- const received = getAgreementArticlesWithPath("1480");
11
+ it(`with an existing agreement IDCC (string)`, () => {
12
+ const received = getAgreementArticlesWithPath("1480");
13
13
 
14
- expect(received[0].path.length).toBeGreaterThan(1);
15
- });
14
+ expect(received[0].path.length).toBeGreaterThan(1);
15
+ });
16
16
 
17
- it(`with an existing agreement IDCC (number)`, () => {
18
- const received = getAgreementArticlesWithPath(1480);
17
+ it(`with an existing agreement IDCC (number)`, () => {
18
+ const received = getAgreementArticlesWithPath(1480);
19
19
 
20
- expect(received[0].path.length).toBeGreaterThan(1);
20
+ expect(received[0].path.length).toBeGreaterThan(1);
21
+ });
21
22
  });
22
- });
23
23
  });
@@ -1,27 +1,27 @@
1
1
  import getAgreementIdFromIdOrIdcc from "../getAgreementIdFromIdOrIdcc";
2
2
 
3
3
  describe(`libs/getAgreementIdFromIdOrIdcc()`, () => {
4
- describe(`should return the expected ID`, () => {
5
- it(`with an existing agreement ID`, () => {
6
- expect(getAgreementIdFromIdOrIdcc("KALICONT000005635444")).toBe("KALICONT000005635444");
7
- });
4
+ describe(`should return the expected ID`, () => {
5
+ it(`with an existing agreement ID`, () => {
6
+ expect(getAgreementIdFromIdOrIdcc("KALICONT000005635444")).toBe("KALICONT000005635444");
7
+ });
8
8
 
9
- it(`with an existing agreement IDCC (string)`, () => {
10
- expect(getAgreementIdFromIdOrIdcc("1480")).toBe("KALICONT000005635444");
11
- });
9
+ it(`with an existing agreement IDCC (string)`, () => {
10
+ expect(getAgreementIdFromIdOrIdcc("1480")).toBe("KALICONT000005635444");
11
+ });
12
12
 
13
- it(`with an existing agreement IDCC (number)`, () => {
14
- expect(getAgreementIdFromIdOrIdcc(1480)).toBe("KALICONT000005635444");
13
+ it(`with an existing agreement IDCC (number)`, () => {
14
+ expect(getAgreementIdFromIdOrIdcc(1480)).toBe("KALICONT000005635444");
15
+ });
15
16
  });
16
- });
17
17
 
18
- describe(`should throw`, () => {
19
- it(`with a malformed input`, () => {
20
- expect(() => getAgreementIdFromIdOrIdcc("MALFORMEDID")).toThrow();
21
- });
18
+ describe(`should throw`, () => {
19
+ it(`with a malformed input`, () => {
20
+ expect(() => getAgreementIdFromIdOrIdcc("MALFORMEDID")).toThrow();
21
+ });
22
22
 
23
- it(`with a nonexistant agreement IDCC`, () => {
24
- expect(() => getAgreementIdFromIdOrIdcc("1234")).toThrow();
23
+ it(`with a nonexistant agreement IDCC`, () => {
24
+ expect(() => getAgreementIdFromIdOrIdcc("1234")).toThrow();
25
+ });
25
26
  });
26
- });
27
27
  });
@@ -1,7 +1,7 @@
1
1
  import getAgreements from "../getAgreements";
2
2
 
3
3
  describe(`libs/getAgreements()`, () => {
4
- it(`should return more than one agreement`, () => {
5
- expect(getAgreements().length).toBeGreaterThan(1);
6
- });
4
+ it(`should return more than one agreement`, () => {
5
+ expect(getAgreements().length).toBeGreaterThan(1);
6
+ });
7
7
  });
@@ -1,29 +1,29 @@
1
1
  import getArticleWithParentSections from "../getArticleWithParentSections";
2
2
 
3
3
  describe(`libs/getArticleWithParentSections()`, () => {
4
- describe(`should match properties`, () => {
5
- it(`with an existing main article ID`, () => {
6
- const received = getArticleWithParentSections("KALIARTI000005781804");
4
+ describe(`should match properties`, () => {
5
+ it(`with an existing main article ID`, () => {
6
+ const received = getArticleWithParentSections("KALIARTI000005781804");
7
7
 
8
- expect(received.data.cid).toBe("KALIARTI000005781804");
9
- expect(received.data.id).toBe("KALIARTI000045466361");
10
- expect(received.sections.length).toBeGreaterThan(1);
11
- });
8
+ expect(received.data.cid).toBe("KALIARTI000005781804");
9
+ expect(received.data.id).toBe("KALIARTI000045466361");
10
+ expect(received.sections.length).toBeGreaterThan(1);
11
+ });
12
12
 
13
- it(`with an existing main article CID`, () => {
14
- const received = getArticleWithParentSections("KALIARTI000005781804");
13
+ it(`with an existing main article CID`, () => {
14
+ const received = getArticleWithParentSections("KALIARTI000005781804");
15
15
 
16
- expect(received.data.cid).toBe("KALIARTI000005781804");
17
- expect(received.data.id).toBe("KALIARTI000045466361");
18
- expect(received.sections.length).toBeGreaterThan(1);
19
- });
16
+ expect(received.data.cid).toBe("KALIARTI000005781804");
17
+ expect(received.data.id).toBe("KALIARTI000045466361");
18
+ expect(received.sections.length).toBeGreaterThan(1);
19
+ });
20
20
 
21
- it(`with an existing additional article ID`, () => {
22
- const received = getArticleWithParentSections("KALIARTI000041787475");
21
+ it(`with an existing additional article ID`, () => {
22
+ const received = getArticleWithParentSections("KALIARTI000041787475");
23
23
 
24
- expect(received.data.cid).toBe("KALIARTI000041787475");
25
- expect(received.data.id).toBe("KALIARTI000041787475");
26
- expect(received.sections.length).toBeGreaterThan(1);
24
+ expect(received.data.cid).toBe("KALIARTI000041787475");
25
+ expect(received.data.id).toBe("KALIARTI000041787475");
26
+ expect(received.sections.length).toBeGreaterThan(1);
27
+ });
27
28
  });
28
- });
29
29
  });
@@ -1,29 +1,29 @@
1
1
  import getArticleWithPath from "../getArticleWithPath";
2
2
 
3
3
  describe(`libs/getArticleWithPath()`, () => {
4
- describe(`should match properties`, () => {
5
- it(`with an existing main article ID`, () => {
6
- const received = getArticleWithPath("KALIARTI000005781818");
4
+ describe(`should match properties`, () => {
5
+ it(`with an existing main article ID`, () => {
6
+ const received = getArticleWithPath("KALIARTI000005781818");
7
7
 
8
- expect(received.data.cid).toBe("KALIARTI000005781818");
9
- expect(received.data.id).toBe("KALIARTI000005781818");
10
- expect(received.path.length).toBeGreaterThan(1);
11
- });
8
+ expect(received.data.cid).toBe("KALIARTI000005781818");
9
+ expect(received.data.id).toBe("KALIARTI000005781818");
10
+ expect(received.path.length).toBeGreaterThan(1);
11
+ });
12
12
 
13
- it(`with an existing main article CID`, () => {
14
- const received = getArticleWithPath("KALIARTI000005781804");
13
+ it(`with an existing main article CID`, () => {
14
+ const received = getArticleWithPath("KALIARTI000005781804");
15
15
 
16
- expect(received.data.cid).toBe("KALIARTI000005781804");
17
- expect(received.data.id).toBe("KALIARTI000045466361");
18
- expect(received.path.length).toBeGreaterThan(1);
19
- });
16
+ expect(received.data.cid).toBe("KALIARTI000005781804");
17
+ expect(received.data.id).toBe("KALIARTI000045466361");
18
+ expect(received.path.length).toBeGreaterThan(1);
19
+ });
20
20
 
21
- it(`with an existing additional article ID`, () => {
22
- const received = getArticleWithPath("KALIARTI000041787475");
21
+ it(`with an existing additional article ID`, () => {
22
+ const received = getArticleWithPath("KALIARTI000041787475");
23
23
 
24
- expect(received.data.cid).toBe("KALIARTI000041787475");
25
- expect(received.data.id).toBe("KALIARTI000041787475");
26
- expect(received.path.length).toBeGreaterThan(1);
24
+ expect(received.data.cid).toBe("KALIARTI000041787475");
25
+ expect(received.data.id).toBe("KALIARTI000041787475");
26
+ expect(received.path.length).toBeGreaterThan(1);
27
+ });
27
28
  });
28
- });
29
29
  });
@@ -1,7 +1,7 @@
1
1
  import getArticles from "../getArticles";
2
2
 
3
3
  describe(`libs/getArticles()`, () => {
4
- it(`should return more than one article`, () => {
5
- expect(getArticles().length).toBeGreaterThan(1);
6
- });
4
+ it(`should return more than one article`, () => {
5
+ expect(getArticles().length).toBeGreaterThan(1);
6
+ });
7
7
  });
@@ -1,27 +1,27 @@
1
1
  import getIndexedArticle from "../getIndexedArticle";
2
2
 
3
3
  describe(`libs/getIndexedArticle()`, () => {
4
- describe(`should match properties`, () => {
5
- it(`with an existing article ID`, () => {
6
- expect(getIndexedArticle("KALIARTI000023306963")).toMatchObject({
7
- agreementId: "KALICONT000005635085",
8
- articleCid: "KALIARTI000005768420",
9
- articleId: "KALIARTI000023306963",
10
- });
11
- });
4
+ describe(`should match properties`, () => {
5
+ it(`with an existing article ID`, () => {
6
+ expect(getIndexedArticle("KALIARTI000023306963")).toMatchObject({
7
+ agreementId: "KALICONT000005635085",
8
+ articleCid: "KALIARTI000005768420",
9
+ articleId: "KALIARTI000023306963",
10
+ });
11
+ });
12
12
 
13
- it(`with an existing article CID`, () => {
14
- expect(getIndexedArticle("KALIARTI000005768420")).toMatchObject({
15
- agreementId: "KALICONT000005635085",
16
- articleCid: "KALIARTI000005768420",
17
- articleId: "KALIARTI000023306963",
18
- });
13
+ it(`with an existing article CID`, () => {
14
+ expect(getIndexedArticle("KALIARTI000005768420")).toMatchObject({
15
+ agreementId: "KALICONT000005635085",
16
+ articleCid: "KALIARTI000005768420",
17
+ articleId: "KALIARTI000023306963",
18
+ });
19
+ });
19
20
  });
20
- });
21
21
 
22
- describe(`should throw`, () => {
23
- it(`with a nonexistent article ID or CID`, () => {
24
- expect(() => getIndexedArticle("KALIARTI123456789012")).toThrow();
22
+ describe(`should throw`, () => {
23
+ it(`with a nonexistent article ID or CID`, () => {
24
+ expect(() => getIndexedArticle("KALIARTI123456789012")).toThrow();
25
+ });
25
26
  });
26
- });
27
27
  });
@@ -1,35 +1,35 @@
1
1
  import hasAgreement from "../hasAgreement";
2
2
 
3
3
  describe(`libs/hasAgreement()`, () => {
4
- describe(`should return true`, () => {
5
- it(`with an existing agreement ID`, () => {
6
- expect(hasAgreement("KALICONT000005635444")).toBe(true);
7
- });
4
+ describe(`should return true`, () => {
5
+ it(`with an existing agreement ID`, () => {
6
+ expect(hasAgreement("KALICONT000005635444")).toBe(true);
7
+ });
8
8
 
9
- it(`with an existing agreement IDCC (string)`, () => {
10
- expect(hasAgreement("1480")).toBe(true);
11
- });
9
+ it(`with an existing agreement IDCC (string)`, () => {
10
+ expect(hasAgreement("1480")).toBe(true);
11
+ });
12
12
 
13
- it(`with an existing agreement IDCC (number)`, () => {
14
- expect(hasAgreement(1480)).toBe(true);
13
+ it(`with an existing agreement IDCC (number)`, () => {
14
+ expect(hasAgreement(1480)).toBe(true);
15
+ });
15
16
  });
16
- });
17
17
 
18
- describe(`should return false`, () => {
19
- it(`with a nonexistant agreement ID`, () => {
20
- expect(hasAgreement("KALICONT000001234567")).toBe(false);
21
- });
18
+ describe(`should return false`, () => {
19
+ it(`with a nonexistant agreement ID`, () => {
20
+ expect(hasAgreement("KALICONT000001234567")).toBe(false);
21
+ });
22
22
 
23
- it(`with a nonexistant agreement IDCC (string)`, () => {
24
- expect(hasAgreement("1234")).toBe(false);
25
- });
23
+ it(`with a nonexistant agreement IDCC (string)`, () => {
24
+ expect(hasAgreement("1234")).toBe(false);
25
+ });
26
26
 
27
- it(`with a nonexistant agreement IDCC (number)`, () => {
28
- expect(hasAgreement(1234)).toBe(false);
29
- });
27
+ it(`with a nonexistant agreement IDCC (number)`, () => {
28
+ expect(hasAgreement(1234)).toBe(false);
29
+ });
30
30
 
31
- it(`with a malformed input`, () => {
32
- expect(hasAgreement("MALFORMEDID")).toBe(false);
31
+ it(`with a malformed input`, () => {
32
+ expect(hasAgreement("MALFORMEDID")).toBe(false);
33
+ });
33
34
  });
34
- });
35
35
  });
@@ -1,23 +1,23 @@
1
1
  import hasArticle from "../hasArticle";
2
2
 
3
3
  describe(`libs/hasArticle()`, () => {
4
- describe(`should return true`, () => {
5
- it(`with an existing article ID`, () => {
6
- expect(hasArticle("KALIARTI000023306963")).toBe(true);
7
- });
4
+ describe(`should return true`, () => {
5
+ it(`with an existing article ID`, () => {
6
+ expect(hasArticle("KALIARTI000023306963")).toBe(true);
7
+ });
8
8
 
9
- it(`with an existing article CID`, () => {
10
- expect(hasArticle("KALIARTI000005768420")).toBe(true);
9
+ it(`with an existing article CID`, () => {
10
+ expect(hasArticle("KALIARTI000005768420")).toBe(true);
11
+ });
11
12
  });
12
- });
13
13
 
14
- describe(`should return false`, () => {
15
- it(`with a nonexistant agreement ID`, () => {
16
- expect(hasArticle("KALIARTI123456789012")).toBe(false);
17
- });
14
+ describe(`should return false`, () => {
15
+ it(`with a nonexistant agreement ID`, () => {
16
+ expect(hasArticle("KALIARTI123456789012")).toBe(false);
17
+ });
18
18
 
19
- it(`with a malformed input`, () => {
20
- expect(hasArticle("MALFORMEDID")).toBe(false);
19
+ it(`with a malformed input`, () => {
20
+ expect(hasArticle("MALFORMEDID")).toBe(false);
21
+ });
21
22
  });
22
- });
23
23
  });
@@ -13,15 +13,15 @@ const hasAgreement = require("./hasAgreement");
13
13
  * @returns {KaliData.Agreement}
14
14
  */
15
15
  function getAgreement(agreementIdOrIdcc) {
16
- const agreementId = getAgreementIdFromIdOrIdcc(agreementIdOrIdcc);
17
- if (!hasAgreement(agreementId)) {
18
- throw new Error(`No agreement found with this ID (${agreementId}).`);
19
- }
16
+ const agreementId = getAgreementIdFromIdOrIdcc(agreementIdOrIdcc);
17
+ if (!hasAgreement(agreementId)) {
18
+ throw new Error(`No agreement found with this ID (${agreementId}).`);
19
+ }
20
20
 
21
- const agreement = require(`../../data/${agreementId}.json`);
22
- const agreementWithParents = unistUtilParents(agreement);
21
+ const agreement = require(`../../data/${agreementId}.json`);
22
+ const agreementWithParents = unistUtilParents(agreement);
23
23
 
24
- return agreementWithParents;
24
+ return agreementWithParents;
25
25
  }
26
26
 
27
27
  module.exports = getAgreement;
@@ -16,28 +16,28 @@ const getArticleWithParentSections = require("./getArticleWithParentSections");
16
16
  * @deprecated Use `getAgreementArticlesWithPath()` instead.
17
17
  */
18
18
  function getAgreementArticlesWithParentSections(agreementIdOrIdcc) {
19
- const agreement = getAgreement(agreementIdOrIdcc);
20
-
21
- const articles =
22
- /** @type {{ children: KaliData.AgreementArticle[], type: "root" }} */
23
- (/** @type {*} */ (unistUtilFlatFilter(agreement, { type: "article" })));
24
- const articleIds = articles.children.map(({ data: { id } }) => id);
25
-
26
- const articlesWithParentSections = articleIds.reduce(
27
- (prevArticlesWithParentSections, articleId) => {
28
- try {
29
- const articleWithParentSections = getArticleWithParentSections(articleId);
30
- // console.log(articleWithParentSections);
31
-
32
- return [...prevArticlesWithParentSections, articleWithParentSections];
33
- } catch (err) {
34
- return prevArticlesWithParentSections;
35
- }
36
- },
37
- [],
38
- );
39
-
40
- return articlesWithParentSections;
19
+ const agreement = getAgreement(agreementIdOrIdcc);
20
+
21
+ const articles =
22
+ /** @type {{ children: KaliData.AgreementArticle[], type: "root" }} */
23
+ (/** @type {*} */ (unistUtilFlatFilter(agreement, { type: "article" })));
24
+ const articleIds = articles.children.map(({ data: { id } }) => id);
25
+
26
+ const articlesWithParentSections = articleIds.reduce(
27
+ (prevArticlesWithParentSections, articleId) => {
28
+ try {
29
+ const articleWithParentSections = getArticleWithParentSections(articleId);
30
+ // console.log(articleWithParentSections);
31
+
32
+ return [...prevArticlesWithParentSections, articleWithParentSections];
33
+ } catch (err) {
34
+ return prevArticlesWithParentSections;
35
+ }
36
+ },
37
+ [],
38
+ );
39
+
40
+ return articlesWithParentSections;
41
41
  }
42
42
 
43
43
  module.exports = getAgreementArticlesWithParentSections;
@@ -14,20 +14,20 @@ const getIndexedArticle = require("./getIndexedArticle");
14
14
  * @returns {KaliData.AgreementArticleWithPath[]}
15
15
  */
16
16
  function getAgreementArticlesWithPath(agreementIdOrIdcc) {
17
- const agreement = getAgreement(agreementIdOrIdcc);
17
+ const agreement = getAgreement(agreementIdOrIdcc);
18
18
 
19
- const rootedArticles =
20
- /** @type {{ children: KaliData.AgreementArticle[], type: "root" }} */
21
- (/** @type {*} */ (unistUtilFlatFilter(agreement, { type: "article" })));
19
+ const rootedArticles =
20
+ /** @type {{ children: KaliData.AgreementArticle[], type: "root" }} */
21
+ (/** @type {*} */ (unistUtilFlatFilter(agreement, { type: "article" })));
22
22
 
23
- if (!rootedArticles) {
24
- return [];
25
- }
23
+ if (!rootedArticles) {
24
+ return [];
25
+ }
26
26
 
27
- return rootedArticles.children.map(article => ({
28
- ...article,
29
- path: getIndexedArticle(article.data.cid).path,
30
- }));
27
+ return rootedArticles.children.map(article => ({
28
+ ...article,
29
+ path: getIndexedArticle(article.data.cid).path,
30
+ }));
31
31
  }
32
32
 
33
33
  module.exports = getAgreementArticlesWithPath;