@natlibfi/marc-record-validators-melinda 11.6.7 → 12.0.0-alpha.12

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 (563) hide show
  1. package/.github/workflows/{melinda-node-tests.yml → melinda-node-tests-and-publish.yml} +37 -12
  2. package/dist/access-rights.js +63 -91
  3. package/dist/access-rights.js.map +7 -1
  4. package/dist/access-rights.test.js +137 -0
  5. package/dist/access-rights.test.js.map +7 -0
  6. package/dist/addMissingField041.js +21 -53
  7. package/dist/addMissingField041.js.map +7 -1
  8. package/dist/addMissingField041.test.js +39 -0
  9. package/dist/addMissingField041.test.js.map +7 -0
  10. package/dist/addMissingField336.js +99 -191
  11. package/dist/addMissingField336.js.map +7 -1
  12. package/dist/addMissingField336.test.js +39 -0
  13. package/dist/addMissingField336.test.js.map +7 -0
  14. package/dist/addMissingField337.js +63 -132
  15. package/dist/addMissingField337.js.map +7 -1
  16. package/dist/addMissingField337.test.js +39 -0
  17. package/dist/addMissingField337.test.js.map +7 -0
  18. package/dist/addMissingField338.js +147 -253
  19. package/dist/addMissingField338.js.map +7 -1
  20. package/dist/addMissingField338.test.js +39 -0
  21. package/dist/addMissingField338.test.js.map +7 -0
  22. package/dist/cyrillux-usemarcon-replacement.js +119 -272
  23. package/dist/cyrillux-usemarcon-replacement.js.map +7 -1
  24. package/dist/cyrillux-usemarcon-replacement.test.js +43 -0
  25. package/dist/cyrillux-usemarcon-replacement.test.js.map +7 -0
  26. package/dist/cyrillux.js +119 -223
  27. package/dist/cyrillux.js.map +7 -1
  28. package/dist/cyrillux.test.js +39 -0
  29. package/dist/cyrillux.test.js.map +7 -0
  30. package/dist/disambiguateSeriesStatements.js +40 -81
  31. package/dist/disambiguateSeriesStatements.js.map +7 -1
  32. package/dist/disambiguateSeriesStatements.test.js +44 -0
  33. package/dist/disambiguateSeriesStatements.test.js.map +7 -0
  34. package/dist/double-commas.js +7 -14
  35. package/dist/double-commas.js.map +7 -1
  36. package/dist/double-commas.test.js +48 -0
  37. package/dist/double-commas.test.js.map +7 -0
  38. package/dist/duplicates-ind1.js +10 -31
  39. package/dist/duplicates-ind1.js.map +7 -1
  40. package/dist/duplicates-ind1.test.js +40 -0
  41. package/dist/duplicates-ind1.test.js.map +7 -0
  42. package/dist/empty-fields.js +10 -22
  43. package/dist/empty-fields.js.map +7 -1
  44. package/dist/empty-fields.test.js +129 -0
  45. package/dist/empty-fields.test.js.map +7 -0
  46. package/dist/ending-punctuation-conf.js +873 -769
  47. package/dist/ending-punctuation-conf.js.map +7 -1
  48. package/dist/ending-punctuation.js +156 -169
  49. package/dist/ending-punctuation.js.map +7 -1
  50. package/dist/ending-punctuation.test.js +2385 -0
  51. package/dist/ending-punctuation.test.js.map +7 -0
  52. package/dist/ending-whitespace.js +10 -35
  53. package/dist/ending-whitespace.js.map +7 -1
  54. package/dist/ending-whitespace.test.js +38 -0
  55. package/dist/ending-whitespace.test.js.map +7 -0
  56. package/dist/field-008-18-34-character-groups.js +40 -125
  57. package/dist/field-008-18-34-character-groups.js.map +7 -1
  58. package/dist/field-008-18-34-character-groups.test.js +45 -0
  59. package/dist/field-008-18-34-character-groups.test.js.map +7 -0
  60. package/dist/field-505-separators.js +19 -39
  61. package/dist/field-505-separators.js.map +7 -1
  62. package/dist/field-505-separators.test.js +45 -0
  63. package/dist/field-505-separators.test.js.map +7 -0
  64. package/dist/field-521-fix.js +19 -47
  65. package/dist/field-521-fix.js.map +7 -1
  66. package/dist/field-521-fix.test.js +44 -0
  67. package/dist/field-521-fix.test.js.map +7 -0
  68. package/dist/field-exclusion.js +37 -91
  69. package/dist/field-exclusion.js.map +7 -1
  70. package/dist/field-exclusion.test.js +821 -0
  71. package/dist/field-exclusion.test.js.map +7 -0
  72. package/dist/field-structure.js +52 -104
  73. package/dist/field-structure.js.map +7 -1
  74. package/dist/field-structure.test.js +587 -0
  75. package/dist/field-structure.test.js.map +7 -0
  76. package/dist/field33XUtils.js +119 -503
  77. package/dist/field33XUtils.js.map +7 -1
  78. package/dist/fields-present.js +11 -23
  79. package/dist/fields-present.js.map +7 -1
  80. package/dist/fields-present.test.js +95 -0
  81. package/dist/fields-present.test.js.map +7 -0
  82. package/dist/fix-33X.js +393 -431
  83. package/dist/fix-33X.js.map +7 -1
  84. package/dist/fix-33X.test.js +39 -0
  85. package/dist/fix-33X.test.js.map +7 -0
  86. package/dist/fix-country-codes.js +20 -50
  87. package/dist/fix-country-codes.js.map +7 -1
  88. package/dist/fix-country-codes.test.js +44 -0
  89. package/dist/fix-country-codes.test.js.map +7 -0
  90. package/dist/fix-language-codes.js +23 -53
  91. package/dist/fix-language-codes.js.map +7 -1
  92. package/dist/fix-language-codes.test.js +38 -0
  93. package/dist/fix-language-codes.test.js.map +7 -0
  94. package/dist/fixRelatorTerms.js +82 -209
  95. package/dist/fixRelatorTerms.js.map +7 -1
  96. package/dist/fixRelatorTerms.test.js +44 -0
  97. package/dist/fixRelatorTerms.test.js.map +7 -0
  98. package/dist/fixed-fields.js +21 -30
  99. package/dist/fixed-fields.js.map +7 -1
  100. package/dist/fixed-fields.test.js +87 -0
  101. package/dist/fixed-fields.test.js.map +7 -0
  102. package/dist/identical-fields.js +8 -24
  103. package/dist/identical-fields.js.map +7 -1
  104. package/dist/identical-fields.test.js +119 -0
  105. package/dist/identical-fields.test.js.map +7 -0
  106. package/dist/index.js +182 -413
  107. package/dist/index.js.map +7 -1
  108. package/dist/indicator-fixes.js +66 -94
  109. package/dist/indicator-fixes.js.map +7 -1
  110. package/dist/indicator-fixes.test.js +42 -0
  111. package/dist/indicator-fixes.test.js.map +7 -0
  112. package/dist/isbn-issn.js +71 -128
  113. package/dist/isbn-issn.js.map +7 -1
  114. package/dist/isbn-issn.test.js +398 -0
  115. package/dist/isbn-issn.test.js.map +7 -0
  116. package/dist/item-language.js +32 -65
  117. package/dist/item-language.js.map +7 -1
  118. package/dist/item-language.test.js +322 -0
  119. package/dist/item-language.test.js.map +7 -0
  120. package/dist/melindaCustomMergeFields.js +5182 -11233
  121. package/dist/melindaCustomMergeFields.js.map +7 -1
  122. package/dist/merge-fields/controlSubfields.js +75 -142
  123. package/dist/merge-fields/controlSubfields.js.map +7 -1
  124. package/dist/merge-fields/counterpartField.js +187 -379
  125. package/dist/merge-fields/counterpartField.js.map +7 -1
  126. package/dist/merge-fields/dataProvenance.js +29 -0
  127. package/dist/merge-fields/dataProvenance.js.map +7 -0
  128. package/dist/merge-fields/index.js +25 -50
  129. package/dist/merge-fields/index.js.map +7 -1
  130. package/dist/merge-fields/mergableIndicator.js +18 -51
  131. package/dist/merge-fields/mergableIndicator.js.map +7 -1
  132. package/dist/merge-fields/mergableTag.js +78 -30
  133. package/dist/merge-fields/mergableTag.js.map +7 -1
  134. package/dist/merge-fields/mergeConfig.js +66 -171
  135. package/dist/merge-fields/mergeConfig.js.map +7 -1
  136. package/dist/merge-fields/mergeConstraints.js +323 -1214
  137. package/dist/merge-fields/mergeConstraints.js.map +7 -1
  138. package/dist/merge-fields/mergeField.js +47 -111
  139. package/dist/merge-fields/mergeField.js.map +7 -1
  140. package/dist/merge-fields/mergeIndicator.js +64 -118
  141. package/dist/merge-fields/mergeIndicator.js.map +7 -1
  142. package/dist/merge-fields/mergeOrAddPostprocess.js +14 -38
  143. package/dist/merge-fields/mergeOrAddPostprocess.js.map +7 -1
  144. package/dist/merge-fields/mergeOrAddSubfield.js +62 -104
  145. package/dist/merge-fields/mergeOrAddSubfield.js.map +7 -1
  146. package/dist/merge-fields/mergeSubfield.js +47 -95
  147. package/dist/merge-fields/mergeSubfield.js.map +7 -1
  148. package/dist/merge-fields/removeDuplicateSubfields.js +18 -31
  149. package/dist/merge-fields/removeDuplicateSubfields.js.map +7 -1
  150. package/dist/merge-fields/worldKnowledge.js +15 -40
  151. package/dist/merge-fields/worldKnowledge.js.map +7 -1
  152. package/dist/merge-fields.test.js +46 -0
  153. package/dist/merge-fields.test.js.map +7 -0
  154. package/dist/mergeField500Lisapainokset.js +27 -56
  155. package/dist/mergeField500Lisapainokset.js.map +7 -1
  156. package/dist/mergeField500Lisapainokset.test.js +44 -0
  157. package/dist/mergeField500Lisapainokset.test.js.map +7 -0
  158. package/dist/mergeRelatorTermFields.js +33 -69
  159. package/dist/mergeRelatorTermFields.js.map +7 -1
  160. package/dist/mergeRelatorTermFields.test.js +44 -0
  161. package/dist/mergeRelatorTermFields.test.js.map +7 -0
  162. package/dist/modernize-502.js +23 -55
  163. package/dist/modernize-502.js.map +7 -1
  164. package/dist/modernize-502.test.js +38 -0
  165. package/dist/modernize-502.test.js.map +7 -0
  166. package/dist/multiple-subfield-0.js +23 -48
  167. package/dist/multiple-subfield-0.js.map +7 -1
  168. package/dist/multiple-subfield-0.test.js +44 -0
  169. package/dist/multiple-subfield-0.test.js.map +7 -0
  170. package/dist/non-breaking-space.js +11 -32
  171. package/dist/non-breaking-space.js.map +7 -1
  172. package/dist/non-breaking-space.test.js +38 -0
  173. package/dist/non-breaking-space.test.js.map +7 -0
  174. package/dist/normalize-dashes.js +18 -37
  175. package/dist/normalize-dashes.js.map +7 -1
  176. package/dist/normalize-dashes.test.js +44 -0
  177. package/dist/normalize-dashes.test.js.map +7 -0
  178. package/dist/normalize-identifiers.js +54 -140
  179. package/dist/normalize-identifiers.js.map +7 -1
  180. package/dist/normalize-identifiers.test.js +44 -0
  181. package/dist/normalize-identifiers.test.js.map +7 -0
  182. package/dist/normalize-qualifying-information.js +23 -48
  183. package/dist/normalize-qualifying-information.js.map +7 -1
  184. package/dist/normalize-qualifying-information.test.js +44 -0
  185. package/dist/normalize-qualifying-information.test.js.map +7 -0
  186. package/dist/normalize-utf8-diacritics.js +19 -105
  187. package/dist/normalize-utf8-diacritics.js.map +7 -1
  188. package/dist/normalize-utf8-diacritics.test.js +44 -0
  189. package/dist/normalize-utf8-diacritics.test.js.map +7 -0
  190. package/dist/normalizeFieldForComparison.js +91 -158
  191. package/dist/normalizeFieldForComparison.js.map +7 -1
  192. package/dist/normalizeSubfieldValueForComparison.js +37 -77
  193. package/dist/normalizeSubfieldValueForComparison.js.map +7 -1
  194. package/dist/prepublicationUtils.js +58 -111
  195. package/dist/prepublicationUtils.js.map +7 -1
  196. package/dist/punctuation/index.js +56 -72
  197. package/dist/punctuation/index.js.map +7 -1
  198. package/dist/punctuation/rules/aut.js +372 -331
  199. package/dist/punctuation/rules/aut.js.map +7 -1
  200. package/dist/punctuation/rules/bib.js +420 -373
  201. package/dist/punctuation/rules/bib.js.map +7 -1
  202. package/dist/punctuation/rules/index.js +7 -21
  203. package/dist/punctuation/rules/index.js.map +7 -1
  204. package/dist/punctuation.test.js +44 -0
  205. package/dist/punctuation.test.js.map +7 -0
  206. package/dist/punctuation2.js +259 -802
  207. package/dist/punctuation2.js.map +7 -1
  208. package/dist/punctuation2.test.js +44 -0
  209. package/dist/punctuation2.test.js.map +7 -0
  210. package/dist/reindexSubfield6OccurenceNumbers.js +61 -96
  211. package/dist/reindexSubfield6OccurenceNumbers.js.map +7 -1
  212. package/dist/reindexSubfield6OccurenceNumbers.test.js +44 -0
  213. package/dist/reindexSubfield6OccurenceNumbers.test.js.map +7 -0
  214. package/dist/removeDuplicateDataFields.js +102 -202
  215. package/dist/removeDuplicateDataFields.js.map +7 -1
  216. package/dist/removeDuplicateDataFields.test.js +44 -0
  217. package/dist/removeDuplicateDataFields.test.js.map +7 -0
  218. package/dist/removeInferiorDataFields.js +104 -227
  219. package/dist/removeInferiorDataFields.js.map +7 -1
  220. package/dist/removeInferiorDataFields.test.js +44 -0
  221. package/dist/removeInferiorDataFields.test.js.map +7 -0
  222. package/dist/resolvable-ext-references-melinda.js +25 -60
  223. package/dist/resolvable-ext-references-melinda.js.map +7 -1
  224. package/dist/resolvable-ext-references-melinda.test.js +160 -0
  225. package/dist/resolvable-ext-references-melinda.test.js.map +7 -0
  226. package/dist/resolveOrphanedSubfield6s.js +32 -63
  227. package/dist/resolveOrphanedSubfield6s.js.map +7 -1
  228. package/dist/resolveOrphanedSubfield6s.test.js +44 -0
  229. package/dist/resolveOrphanedSubfield6s.test.js.map +7 -0
  230. package/dist/sanitize-vocabulary-source-codes.js +27 -55
  231. package/dist/sanitize-vocabulary-source-codes.js.map +7 -1
  232. package/dist/sanitize-vocabulary-source-codes.test.js +45 -0
  233. package/dist/sanitize-vocabulary-source-codes.test.js.map +7 -0
  234. package/dist/sort-tags.js +13 -25
  235. package/dist/sort-tags.js.map +7 -1
  236. package/dist/sort-tags.test.js +261 -0
  237. package/dist/sort-tags.test.js.map +7 -0
  238. package/dist/sortFields.js +152 -222
  239. package/dist/sortFields.js.map +7 -1
  240. package/dist/sortFields.test.js +44 -0
  241. package/dist/sortFields.test.js.map +7 -0
  242. package/dist/sortRelatorTerms.js +30 -68
  243. package/dist/sortRelatorTerms.js.map +7 -1
  244. package/dist/sortRelatorTerms.test.js +44 -0
  245. package/dist/sortRelatorTerms.test.js.map +7 -0
  246. package/dist/sortSubfields.js +102 -255
  247. package/dist/sortSubfields.js.map +7 -1
  248. package/dist/sortSubfields.test.js +44 -0
  249. package/dist/sortSubfields.test.js.map +7 -0
  250. package/dist/stripPunctuation.js +13 -36
  251. package/dist/stripPunctuation.js.map +7 -1
  252. package/dist/stripPunctuation.test.js +44 -0
  253. package/dist/stripPunctuation.test.js.map +7 -0
  254. package/dist/subfield-exclusion.js +28 -75
  255. package/dist/subfield-exclusion.js.map +7 -1
  256. package/dist/subfield-exclusion.test.js +471 -0
  257. package/dist/subfield-exclusion.test.js.map +7 -0
  258. package/dist/subfield6Utils.js +107 -269
  259. package/dist/subfield6Utils.js.map +7 -1
  260. package/dist/subfield8Utils.js +26 -50
  261. package/dist/subfield8Utils.js.map +7 -1
  262. package/dist/subfieldValueNormalizations.js +40 -74
  263. package/dist/subfieldValueNormalizations.js.map +7 -1
  264. package/dist/subfieldValueNormalizations.test.js +45 -0
  265. package/dist/subfieldValueNormalizations.test.js.map +7 -0
  266. package/dist/sync-007-and-300.js +22 -53
  267. package/dist/sync-007-and-300.js.map +7 -1
  268. package/dist/sync-007-and-300.test.js +44 -0
  269. package/dist/sync-007-and-300.test.js.map +7 -0
  270. package/dist/translate-terms.js +67 -155
  271. package/dist/translate-terms.js.map +7 -1
  272. package/dist/translate-terms.test.js +54 -0
  273. package/dist/translate-terms.test.js.map +7 -0
  274. package/dist/typeOfDate-008.js +10 -25
  275. package/dist/typeOfDate-008.js.map +7 -1
  276. package/dist/typeOfDate-008.test.js +40 -0
  277. package/dist/typeOfDate-008.test.js.map +7 -0
  278. package/dist/unicode-decomposition.js +94 -107
  279. package/dist/unicode-decomposition.js.map +7 -1
  280. package/dist/unicode-decomposition.test.js +94 -0
  281. package/dist/unicode-decomposition.test.js.map +7 -0
  282. package/dist/update-field-540.js +30 -75
  283. package/dist/update-field-540.js.map +7 -1
  284. package/dist/update-field-540.test.js +44 -0
  285. package/dist/update-field-540.test.js.map +7 -0
  286. package/dist/urn.js +55 -128
  287. package/dist/urn.js.map +7 -1
  288. package/dist/urn.test.js +44 -0
  289. package/dist/urn.test.js.map +7 -0
  290. package/dist/utils.js +78 -126
  291. package/dist/utils.js.map +7 -1
  292. package/eslint.config.mjs +1 -2
  293. package/package.json +28 -101
  294. package/src/access-rights.js +1 -1
  295. package/src/{access-rights.spec.js → access-rights.test.js} +9 -10
  296. package/src/addMissingField041.js +1 -1
  297. package/src/{addMissingField336.spec.js → addMissingField041.test.js} +13 -14
  298. package/src/addMissingField336.js +3 -3
  299. package/src/{addMissingField041.spec.js → addMissingField336.test.js} +13 -14
  300. package/src/addMissingField337.js +2 -2
  301. package/src/{addMissingField337.spec.js → addMissingField337.test.js} +13 -14
  302. package/src/addMissingField338.js +2 -2
  303. package/src/{addMissingField338.spec.js → addMissingField338.test.js} +13 -14
  304. package/src/cyrillux-usemarcon-replacement.js +18 -18
  305. package/src/{cyrillux-usemarcon-replacement.spec.js → cyrillux-usemarcon-replacement.test.js} +17 -14
  306. package/src/cyrillux.js +19 -12
  307. package/src/{cyrillux.spec.js → cyrillux.test.js} +13 -14
  308. package/src/disambiguateSeriesStatements.js +2 -2
  309. package/src/{disambiguateSeriesStatements.spec.js → disambiguateSeriesStatements.test.js} +12 -13
  310. package/src/double-commas.js +1 -1
  311. package/src/{double-commas.spec.js → double-commas.test.js} +9 -11
  312. package/src/duplicates-ind1.js +1 -1
  313. package/src/{duplicates-ind1.spec.js → duplicates-ind1.test.js} +12 -13
  314. package/src/{empty-fields.spec.js → empty-fields.test.js} +11 -13
  315. package/src/ending-punctuation-conf.js +6 -5
  316. package/src/ending-punctuation.js +115 -24
  317. package/src/{ending-punctuation.spec.js → ending-punctuation.test.js} +357 -275
  318. package/src/{ending-whitespace.spec.js → ending-whitespace.test.js} +12 -13
  319. package/src/field-008-18-34-character-groups.js +2 -2
  320. package/src/{field-008-18-34-character-groups.spec.js → field-008-18-34-character-groups.test.js} +13 -13
  321. package/src/field-505-separators.js +3 -3
  322. package/src/{field-505-separators.spec.js → field-505-separators.test.js} +16 -14
  323. package/src/field-521-fix.js +2 -2
  324. package/src/{field-521-fix.spec.js → field-521-fix.test.js} +12 -13
  325. package/src/field-exclusion.js +1 -1
  326. package/src/{field-exclusion.spec.js → field-exclusion.test.js} +60 -57
  327. package/src/{field-structure.spec.js → field-structure.test.js} +29 -29
  328. package/src/{fields-present.spec.js → fields-present.test.js} +12 -15
  329. package/src/fix-33X.js +4 -4
  330. package/src/{fix-33X.spec.js → fix-33X.test.js} +13 -14
  331. package/src/fix-country-codes.js +1 -1
  332. package/src/{fix-country-codes.spec.js → fix-country-codes.test.js} +12 -13
  333. package/src/fix-language-codes.js +5 -5
  334. package/src/{fix-language-codes.spec.js → fix-language-codes.test.js} +12 -13
  335. package/src/fixRelatorTerms.js +5 -5
  336. package/src/{fixRelatorTerms.spec.js → fixRelatorTerms.test.js} +13 -13
  337. package/src/{fixed-fields.spec.js → fixed-fields.test.js} +11 -14
  338. package/src/identical-fields.js +1 -1
  339. package/src/{identical-fields.spec.js → identical-fields.test.js} +9 -11
  340. package/src/index.js +132 -59
  341. package/src/indicator-fixes.js +17 -4
  342. package/src/{indicator-fixes.spec.js → indicator-fixes.test.js} +9 -12
  343. package/src/isbn-issn.js +12 -7
  344. package/src/{isbn-issn.spec.js → isbn-issn.test.js} +20 -22
  345. package/src/{item-language.spec.js → item-language.test.js} +21 -22
  346. package/src/melindaCustomMergeFields.js +1 -1
  347. package/src/merge-fields/controlSubfields.js +1 -1
  348. package/src/merge-fields/counterpartField.js +14 -9
  349. package/src/merge-fields/dataProvenance.js +41 -0
  350. package/src/merge-fields/index.js +12 -3
  351. package/src/merge-fields/mergableIndicator.js +1 -1
  352. package/src/merge-fields/mergeField.js +8 -8
  353. package/src/merge-fields/mergeIndicator.js +1 -1
  354. package/src/merge-fields/mergeOrAddPostprocess.js +4 -4
  355. package/src/merge-fields/mergeOrAddSubfield.js +2 -2
  356. package/src/merge-fields/mergeSubfield.js +4 -4
  357. package/src/merge-fields/removeDuplicateSubfields.js +2 -2
  358. package/src/{merge-fields.spec.js → merge-fields.test.js} +18 -15
  359. package/src/mergeField500Lisapainokset.js +1 -1
  360. package/src/{mergeField500Lisapainokset.spec.js → mergeField500Lisapainokset.test.js} +12 -13
  361. package/src/mergeRelatorTermFields.js +5 -7
  362. package/src/{mergeRelatorTermFields.spec.js → mergeRelatorTermFields.test.js} +12 -13
  363. package/src/modernize-502.js +1 -1
  364. package/src/{modernize-502.spec.js → modernize-502.test.js} +12 -13
  365. package/src/multiple-subfield-0.js +3 -3
  366. package/src/{multiple-subfield-0.spec.js → multiple-subfield-0.test.js} +13 -13
  367. package/src/{non-breaking-space.spec.js → non-breaking-space.test.js} +12 -13
  368. package/src/normalize-dashes.js +2 -2
  369. package/src/{normalize-dashes.spec.js → normalize-dashes.test.js} +12 -13
  370. package/src/normalize-identifiers.js +1 -1
  371. package/src/{normalize-identifiers.spec.js → normalize-identifiers.test.js} +12 -13
  372. package/src/normalize-qualifying-information.js +2 -2
  373. package/src/{normalize-qualifying-information.spec.js → normalize-qualifying-information.test.js} +12 -13
  374. package/src/normalize-utf8-diacritics.js +2 -2
  375. package/src/{normalize-utf8-diacritics.spec.js → normalize-utf8-diacritics.test.js} +13 -13
  376. package/src/normalizeFieldForComparison.js +32 -6
  377. package/src/normalizeSubfieldValueForComparison.js +1 -1
  378. package/src/prepublicationUtils.js +4 -4
  379. package/src/punctuation/index.js +1 -1
  380. package/src/punctuation/rules/index.js +2 -2
  381. package/src/{punctuation.spec.js → punctuation.test.js} +12 -13
  382. package/src/punctuation2.js +17 -8
  383. package/src/{punctuation2.spec.js → punctuation2.test.js} +12 -13
  384. package/src/reindexSubfield6OccurenceNumbers.js +5 -7
  385. package/src/{reindexSubfield6OccurenceNumbers.spec.js → reindexSubfield6OccurenceNumbers.test.js} +12 -13
  386. package/src/removeDuplicateDataFields.js +11 -19
  387. package/src/{removeDuplicateDataFields.spec.js → removeDuplicateDataFields.test.js} +12 -13
  388. package/src/removeInferiorDataFields.js +15 -12
  389. package/src/{removeInferiorDataFields.spec.js → removeInferiorDataFields.test.js} +13 -13
  390. package/src/resolvable-ext-references-melinda.js +1 -1
  391. package/src/{resolvable-ext-references-melinda.spec.js → resolvable-ext-references-melinda.test.js} +42 -27
  392. package/src/resolveOrphanedSubfield6s.js +6 -6
  393. package/src/{resolveOrphanedSubfield6s.spec.js → resolveOrphanedSubfield6s.test.js} +13 -13
  394. package/src/sanitize-vocabulary-source-codes.js +4 -4
  395. package/src/{sanitize-vocabulary-source-codes.spec.js → sanitize-vocabulary-source-codes.test.js} +16 -14
  396. package/src/{sort-tags.spec.js → sort-tags.test.js} +9 -11
  397. package/src/sortFields.js +4 -4
  398. package/src/{sortFields.spec.js → sortFields.test.js} +12 -13
  399. package/src/sortRelatorTerms.js +3 -3
  400. package/src/{sortRelatorTerms.spec.js → sortRelatorTerms.test.js} +13 -13
  401. package/src/sortSubfields.js +8 -6
  402. package/src/{sortSubfields.spec.js → sortSubfields.test.js} +13 -13
  403. package/src/stripPunctuation.js +3 -3
  404. package/src/{stripPunctuation.spec.js → stripPunctuation.test.js} +13 -13
  405. package/src/subfield-exclusion.js +1 -1
  406. package/src/{subfield-exclusion.spec.js → subfield-exclusion.test.js} +45 -36
  407. package/src/subfield6Utils.js +6 -10
  408. package/src/subfield8Utils.js +4 -4
  409. package/src/subfieldValueNormalizations.js +3 -3
  410. package/src/{subfieldValueNormalizations.spec.js → subfieldValueNormalizations.test.js} +18 -14
  411. package/src/sync-007-and-300.js +2 -2
  412. package/src/{sync-007-and-300.spec.js → sync-007-and-300.test.js} +13 -13
  413. package/src/translate-terms.js +3 -3
  414. package/src/translate-terms.test.js +75 -0
  415. package/src/{typeOfDate-008.spec.js → typeOfDate-008.test.js} +12 -13
  416. package/src/{unicode-decomposition.spec.js → unicode-decomposition.test.js} +10 -16
  417. package/src/update-field-540.js +2 -2
  418. package/src/{update-field-540.spec.js → update-field-540.test.js} +13 -10
  419. package/src/urn.js +2 -2
  420. package/src/{urn.spec.js → urn.test.js} +12 -13
  421. package/src/utils.js +21 -5
  422. package/test-fixtures/field-505-separators/03/expectedResult.json +3 -1
  423. package/test-fixtures/field-505-separators/03/record.json +3 -0
  424. package/test-fixtures/indicator-fixes/10/expectedResult.json +11 -0
  425. package/test-fixtures/indicator-fixes/10/metadata.json +4 -0
  426. package/test-fixtures/indicator-fixes/10/record.json +11 -0
  427. package/test-fixtures/merge-fields/f05/expectedResult.json +24 -0
  428. package/test-fixtures/merge-fields/f05/metadata.json +6 -0
  429. package/test-fixtures/merge-fields/f05/record.json +30 -0
  430. package/test-fixtures/normalize-subfield-value/01/metadata.json +4 -1
  431. package/test-fixtures/normalize-subfield-value/01/record.json +3 -0
  432. package/test-fixtures/normalize-subfield-value/02/expectedResult.json +3 -1
  433. package/test-fixtures/normalize-subfield-value/02/metadata.json +2 -1
  434. package/test-fixtures/normalize-subfield-value/02/record.json +3 -0
  435. package/test-fixtures/remove-inferior-datafields/f16/expectedResult.json +12 -0
  436. package/test-fixtures/remove-inferior-datafields/f16/metadata.json +5 -0
  437. package/test-fixtures/remove-inferior-datafields/f16/record.json +14 -0
  438. package/test-fixtures/sanitize-vocabulary-source-codes/f03/expectedResult.json +3 -1
  439. package/test-fixtures/sanitize-vocabulary-source-codes/f04/expectedResult.json +3 -1
  440. package/test-fixtures/sanitize-vocabulary-source-codes/v04/metadata.json +1 -4
  441. package/test-fixtures/sanitize-vocabulary-source-codes/v04/record.json +1 -1
  442. package/test-fixtures/translate-terms-data.js +42 -0
  443. package/dist/access-rights.spec.js +0 -195
  444. package/dist/access-rights.spec.js.map +0 -1
  445. package/dist/addMissingField041.spec.js +0 -45
  446. package/dist/addMissingField041.spec.js.map +0 -1
  447. package/dist/addMissingField336.spec.js +0 -45
  448. package/dist/addMissingField336.spec.js.map +0 -1
  449. package/dist/addMissingField337.spec.js +0 -43
  450. package/dist/addMissingField337.spec.js.map +0 -1
  451. package/dist/addMissingField338.spec.js +0 -45
  452. package/dist/addMissingField338.spec.js.map +0 -1
  453. package/dist/cyrillux-usemarcon-replacement.spec.js +0 -45
  454. package/dist/cyrillux-usemarcon-replacement.spec.js.map +0 -1
  455. package/dist/cyrillux.spec.js +0 -46
  456. package/dist/cyrillux.spec.js.map +0 -1
  457. package/dist/disambiguateSeriesStatements.spec.js +0 -51
  458. package/dist/disambiguateSeriesStatements.spec.js.map +0 -1
  459. package/dist/double-commas.spec.js +0 -73
  460. package/dist/double-commas.spec.js.map +0 -1
  461. package/dist/duplicates-ind1.spec.js +0 -45
  462. package/dist/duplicates-ind1.spec.js.map +0 -1
  463. package/dist/empty-fields.spec.js +0 -118
  464. package/dist/empty-fields.spec.js.map +0 -1
  465. package/dist/ending-punctuation.spec.js +0 -2654
  466. package/dist/ending-punctuation.spec.js.map +0 -1
  467. package/dist/ending-whitespace.spec.js +0 -42
  468. package/dist/ending-whitespace.spec.js.map +0 -1
  469. package/dist/field-008-18-34-character-groups.spec.js +0 -51
  470. package/dist/field-008-18-34-character-groups.spec.js.map +0 -1
  471. package/dist/field-505-separators.spec.js +0 -51
  472. package/dist/field-505-separators.spec.js.map +0 -1
  473. package/dist/field-521-fix.spec.js +0 -51
  474. package/dist/field-521-fix.spec.js.map +0 -1
  475. package/dist/field-exclusion.spec.js +0 -1054
  476. package/dist/field-exclusion.spec.js.map +0 -1
  477. package/dist/field-structure.spec.js +0 -535
  478. package/dist/field-structure.spec.js.map +0 -1
  479. package/dist/fields-present.spec.js +0 -121
  480. package/dist/fields-present.spec.js.map +0 -1
  481. package/dist/fix-33X.spec.js +0 -45
  482. package/dist/fix-33X.spec.js.map +0 -1
  483. package/dist/fix-country-codes.spec.js +0 -51
  484. package/dist/fix-country-codes.spec.js.map +0 -1
  485. package/dist/fix-language-codes.spec.js +0 -44
  486. package/dist/fix-language-codes.spec.js.map +0 -1
  487. package/dist/fixRelatorTerms.spec.js +0 -51
  488. package/dist/fixRelatorTerms.spec.js.map +0 -1
  489. package/dist/fixed-fields.spec.js +0 -140
  490. package/dist/fixed-fields.spec.js.map +0 -1
  491. package/dist/identical-fields.spec.js +0 -99
  492. package/dist/identical-fields.spec.js.map +0 -1
  493. package/dist/indicator-fixes.spec.js +0 -51
  494. package/dist/indicator-fixes.spec.js.map +0 -1
  495. package/dist/isbn-issn.spec.js +0 -595
  496. package/dist/isbn-issn.spec.js.map +0 -1
  497. package/dist/item-language.spec.js +0 -306
  498. package/dist/item-language.spec.js.map +0 -1
  499. package/dist/melindaCustomMergeFields.json +0 -5120
  500. package/dist/merge-fields.spec.js +0 -51
  501. package/dist/merge-fields.spec.js.map +0 -1
  502. package/dist/mergeField500Lisapainokset.spec.js +0 -51
  503. package/dist/mergeField500Lisapainokset.spec.js.map +0 -1
  504. package/dist/mergeRelatorTermFields.spec.js +0 -51
  505. package/dist/mergeRelatorTermFields.spec.js.map +0 -1
  506. package/dist/modernize-502.spec.js +0 -49
  507. package/dist/modernize-502.spec.js.map +0 -1
  508. package/dist/multiple-subfield-0.spec.js +0 -51
  509. package/dist/multiple-subfield-0.spec.js.map +0 -1
  510. package/dist/non-breaking-space.spec.js +0 -42
  511. package/dist/non-breaking-space.spec.js.map +0 -1
  512. package/dist/normalize-dashes.spec.js +0 -51
  513. package/dist/normalize-dashes.spec.js.map +0 -1
  514. package/dist/normalize-identifiers.spec.js +0 -51
  515. package/dist/normalize-identifiers.spec.js.map +0 -1
  516. package/dist/normalize-qualifying-information.spec.js +0 -51
  517. package/dist/normalize-qualifying-information.spec.js.map +0 -1
  518. package/dist/normalize-utf8-diacritics.spec.js +0 -51
  519. package/dist/normalize-utf8-diacritics.spec.js.map +0 -1
  520. package/dist/punctuation.spec.js +0 -51
  521. package/dist/punctuation.spec.js.map +0 -1
  522. package/dist/punctuation2.spec.js +0 -51
  523. package/dist/punctuation2.spec.js.map +0 -1
  524. package/dist/reindexSubfield6OccurenceNumbers.spec.js +0 -51
  525. package/dist/reindexSubfield6OccurenceNumbers.spec.js.map +0 -1
  526. package/dist/removeDuplicateDataFields.spec.js +0 -51
  527. package/dist/removeDuplicateDataFields.spec.js.map +0 -1
  528. package/dist/removeInferiorDataFields.spec.js +0 -51
  529. package/dist/removeInferiorDataFields.spec.js.map +0 -1
  530. package/dist/resolvable-ext-references-melinda.spec.js +0 -166
  531. package/dist/resolvable-ext-references-melinda.spec.js.map +0 -1
  532. package/dist/resolveOrphanedSubfield6s.spec.js +0 -51
  533. package/dist/resolveOrphanedSubfield6s.spec.js.map +0 -1
  534. package/dist/sanitize-vocabulary-source-codes.spec.js +0 -51
  535. package/dist/sanitize-vocabulary-source-codes.spec.js.map +0 -1
  536. package/dist/sort-tags.spec.js +0 -207
  537. package/dist/sort-tags.spec.js.map +0 -1
  538. package/dist/sortFields.spec.js +0 -51
  539. package/dist/sortFields.spec.js.map +0 -1
  540. package/dist/sortRelatorTerms.spec.js +0 -51
  541. package/dist/sortRelatorTerms.spec.js.map +0 -1
  542. package/dist/sortSubfields.spec.js +0 -52
  543. package/dist/sortSubfields.spec.js.map +0 -1
  544. package/dist/stripPunctuation.spec.js +0 -51
  545. package/dist/stripPunctuation.spec.js.map +0 -1
  546. package/dist/subfield-exclusion.spec.js +0 -523
  547. package/dist/subfield-exclusion.spec.js.map +0 -1
  548. package/dist/subfieldValueNormalizations.spec.js +0 -51
  549. package/dist/subfieldValueNormalizations.spec.js.map +0 -1
  550. package/dist/sync-007-and-300.spec.js +0 -51
  551. package/dist/sync-007-and-300.spec.js.map +0 -1
  552. package/dist/translate-terms.spec.js +0 -51
  553. package/dist/translate-terms.spec.js.map +0 -1
  554. package/dist/typeOfDate-008.spec.js +0 -47
  555. package/dist/typeOfDate-008.spec.js.map +0 -1
  556. package/dist/unicode-decomposition.spec.js +0 -91
  557. package/dist/unicode-decomposition.spec.js.map +0 -1
  558. package/dist/update-field-540.spec.js +0 -51
  559. package/dist/update-field-540.spec.js.map +0 -1
  560. package/dist/urn.spec.js +0 -52
  561. package/dist/urn.spec.js.map +0 -1
  562. package/src/melindaCustomMergeFields.json +0 -5120
  563. package/src/translate-terms.spec.js +0 -52
@@ -1,2654 +0,0 @@
1
- "use strict";
2
-
3
- var _chai = _interopRequireDefault(require("chai"));
4
- var _chaiAsPromised = _interopRequireDefault(require("chai-as-promised"));
5
- var _marcRecord = require("@natlibfi/marc-record");
6
- var _endingPunctuation = _interopRequireDefault(require("../src/ending-punctuation"));
7
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
- const {
9
- expect
10
- } = _chai.default;
11
- _chai.default.use(_chaiAsPromised.default);
12
-
13
- // Factory validation
14
- describe('ending-punctuation', () => {
15
- // Indicators and subfields validation
16
- describe('#validate: Indicators and subfields', () => {
17
- const recordValid = new _marcRecord.MarcRecord({
18
- leader: '',
19
- fields: [{
20
- tag: '245',
21
- ind1: ' ',
22
- ind2: ' ',
23
- subfields: [{
24
- code: 'a',
25
- value: 'Elämäni ja tutkimusretkeni / '
26
- }, {
27
- code: 'c',
28
- value: 'Roald Amundsen ; suomentanut Sulo Veikko Pekkola.'
29
- }, {
30
- code: '6',
31
- value: 'FOO'
32
- }]
33
- }, {
34
- tag: '337',
35
- // Range 336-338
36
- ind1: ' ',
37
- ind2: ' ',
38
- subfields: [{
39
- code: 'a',
40
- value: 'käytettävissä ilman laitetta'
41
- }, {
42
- code: 'b',
43
- value: 'n'
44
- }, {
45
- code: '2',
46
- value: 'rdamedia'
47
- }]
48
- }, {
49
- tag: '500',
50
- // Range 500-509
51
- ind1: ' ',
52
- ind2: ' ',
53
- subfields: [{
54
- code: 'a',
55
- value: 'FOO (Bar)'
56
- }]
57
- }]
58
- });
59
- const recordInvalid = new _marcRecord.MarcRecord({
60
- leader: '',
61
- fields: [{
62
- tag: '245',
63
- ind1: ' ',
64
- ind2: ' ',
65
- subfields: [{
66
- code: 'a',
67
- value: 'Elämäni ja tutkimusretkeni / '
68
- }, {
69
- code: 'c',
70
- value: 'Roald Amundsen ; suomentanut Sulo Veikko Pekkola'
71
- }, {
72
- code: '6',
73
- value: 'FOO'
74
- }]
75
- }, {
76
- tag: '337',
77
- ind1: ' ',
78
- ind2: ' ',
79
- subfields: [{
80
- code: 'a',
81
- value: 'käytettävissä ilman laitetta'
82
- }, {
83
- code: 'b',
84
- value: 'n.'
85
- },
86
- // This can be abbreviation -> does not generate error
87
- {
88
- code: '2',
89
- value: 'rdamedia'
90
- }]
91
- }, {
92
- tag: '500',
93
- ind1: ' ',
94
- ind2: ' ',
95
- subfields: [{
96
- code: 'a',
97
- value: 'FOO (Bar).'
98
- }]
99
- }]
100
- });
101
- const recordBroken = new _marcRecord.MarcRecord({
102
- leader: '',
103
- fields: [{
104
- tag: '245',
105
- ind1: ' ',
106
- ind2: ' ',
107
- subfields: [{
108
- code: 'a',
109
- value: 'Elämäni ja tutkimusretkeni / '
110
- }, {
111
- code: 'c',
112
- value: 'Roald Amundsen ; suomentanut Sulo Veikko Pekkola'
113
- }, {
114
- code: '6',
115
- value: 'FOO'
116
- }]
117
- }, {
118
- tag: '337',
119
- ind1: ' ',
120
- ind2: ' ',
121
- subfields: [{
122
- code: 'a',
123
- value: 'käytettävissä ilman laitetta'
124
- }, {
125
- code: 'b',
126
- value: 'n'
127
- },
128
- // Dot removed from possible abbreviation as it cannot be removed in fixing
129
- {
130
- code: '2',
131
- value: 'rdamedia'
132
- }]
133
- }, {
134
- tag: '500',
135
- ind1: ' ',
136
- ind2: ' ',
137
- subfields: [{
138
- code: 'a',
139
- value: 'FOO (Bar).'
140
- }]
141
- }]
142
- });
143
- it('Finds the record valid', async () => {
144
- const validator = await (0, _endingPunctuation.default)();
145
- const result = await validator.validate(recordValid);
146
- expect(result.valid).to.eql(true);
147
- });
148
- it('Finds the record invalid', async () => {
149
- const validator = await (0, _endingPunctuation.default)();
150
- const result = await validator.validate(recordInvalid);
151
- expect(result).to.eql({
152
- message: ['Field 245 has invalid ending punctuation', 'Field 500 has invalid ending punctuation'],
153
- valid: false
154
- });
155
- });
156
- it('Repairs the invalid record', async () => {
157
- const validator = await (0, _endingPunctuation.default)();
158
- const result = await validator.fix(recordBroken);
159
- expect(recordBroken.equalsTo(recordValid)).to.eql(true);
160
- expect(result).to.eql({
161
- message: ['Field 245 has invalid ending punctuation', 'Field 500 has invalid ending punctuation'],
162
- fix: ['Field 245 - Added punctuation to $c', 'Field 500 - Removed double punctuation from $a'],
163
- valid: false
164
- });
165
- });
166
- });
167
- describe('#specials', () => {
168
- // "036 KYLLÄ vain osakentän $b jälkeen"
169
- // Can have subfields a and b, dot only after b
170
- describe('#036 TRUE - only after subfield $b', () => {
171
- // Valid tests
172
- const recordValid = new _marcRecord.MarcRecord({
173
- leader: '',
174
- fields: [{
175
- tag: '036',
176
- ind1: ' ',
177
- ind2: ' ',
178
- subfields: [{
179
- code: 'a',
180
- value: 'CNRS 84115'
181
- }, {
182
- code: 'b',
183
- value: 'Centre national de la recherche scientifique.'
184
- }]
185
- }]
186
- });
187
- const recordValidOnlyA = new _marcRecord.MarcRecord({
188
- leader: '',
189
- fields: [{
190
- tag: '036',
191
- ind1: ' ',
192
- ind2: ' ',
193
- subfields: [{
194
- code: 'a',
195
- value: 'CNRS 84115'
196
- }]
197
- }]
198
- });
199
- it('Finds record valid - Punc $b', async () => {
200
- const validator = await (0, _endingPunctuation.default)();
201
- const result = await validator.validate(recordValid);
202
- expect(result.valid).to.eql(true);
203
- });
204
- it('Finds record valid - Only $a without punc', async () => {
205
- const validator = await (0, _endingPunctuation.default)();
206
- const result = await validator.validate(recordValidOnlyA);
207
- expect(result.valid).to.eql(true);
208
- });
209
-
210
- // Invalid tests
211
- const recordInvalid = new _marcRecord.MarcRecord({
212
- leader: '',
213
- fields: [{
214
- tag: '036',
215
- ind1: ' ',
216
- ind2: ' ',
217
- subfields: [{
218
- code: 'a',
219
- value: 'CNRS 84115'
220
- }, {
221
- code: 'b',
222
- value: 'Centre national de la recherche scientifique'
223
- }]
224
- }]
225
- });
226
- const recordInvalidOnlyA = new _marcRecord.MarcRecord({
227
- leader: '',
228
- fields: [{
229
- tag: '036',
230
- ind1: ' ',
231
- ind2: ' ',
232
- subfields: [{
233
- code: 'a',
234
- value: 'CNRS 84115.'
235
- }] // $a is register number, no change for abbreviation
236
- }]
237
- });
238
- it('Finds record invalid - No punc $b', async () => {
239
- const validator = await (0, _endingPunctuation.default)();
240
- const result = await validator.validate(recordInvalid);
241
- expect(result).to.eql({
242
- message: ['Field 036 has invalid ending punctuation'],
243
- valid: false
244
- });
245
- });
246
- it('Finds record invalid - Only $a with punc', async () => {
247
- const validator = await (0, _endingPunctuation.default)();
248
- const result = await validator.validate(recordInvalidOnlyA);
249
- expect(result).to.eql({
250
- message: ['Field 036 has invalid ending punctuation'],
251
- valid: false
252
- });
253
- });
254
-
255
- // Fix tests; invalid->valid
256
- it('Repairs the invalid record - Add punc $b', async () => {
257
- const validator = await (0, _endingPunctuation.default)();
258
- const result = await validator.fix(recordInvalid);
259
- expect(recordInvalid.equalsTo(recordValid)).to.eql(true);
260
- expect(result).to.eql({
261
- message: ['Field 036 has invalid ending punctuation'],
262
- fix: ['Field 036 - Added punctuation to $b'],
263
- valid: false
264
- });
265
- });
266
- it('Repairs the invalid record - Removes punc $a (register)', async () => {
267
- const validator = await (0, _endingPunctuation.default)();
268
- const result = await validator.fix(recordInvalidOnlyA);
269
- expect(recordInvalidOnlyA.equalsTo(recordValidOnlyA)).to.eql(true);
270
- expect(result).to.eql({
271
- message: ['Field 036 has invalid ending punctuation'],
272
- fix: ['Field 036 - Removed punctuation from $a'],
273
- valid: false
274
- });
275
- });
276
- });
277
-
278
- // "242 KYLLÄ Jos viimeinen osakenttä on $y, piste on ennen sitä" - Eli siis ei kentässä y (ennen sitä)
279
- describe('#242 TRUE - if last subfield $y, punc before it', () => {
280
- // Valid tests
281
- const recordValidOnlyA = new _marcRecord.MarcRecord({
282
- leader: '',
283
- fields: [{
284
- tag: '242',
285
- ind1: ' ',
286
- ind2: ' ',
287
- subfields: [{
288
- code: 'a',
289
- value: 'World of art.'
290
- }, {
291
- code: 'y',
292
- value: 'eng'
293
- }]
294
- }]
295
- });
296
- const recordValidMultiple = new _marcRecord.MarcRecord({
297
- leader: '',
298
- fields: [{
299
- tag: '242',
300
- ind1: ' ',
301
- ind2: ' ',
302
- subfields: [{
303
- code: 'a',
304
- value: 'Annals of chemistry.'
305
- }, {
306
- code: 'n',
307
- value: 'Series C,'
308
- }, {
309
- code: 'p',
310
- value: 'Organic chemistry and biochemistry.'
311
- }, {
312
- code: 'y',
313
- value: 'eng'
314
- }]
315
- }]
316
- });
317
-
318
- // "Suositellaan käytettäväksi myös osakenttää ‡y (käännöksen kielikoodi)." https://www.kiwi.fi/pages/viewpage.action?pageId=51282044
319
- const recordValidWithoutY = new _marcRecord.MarcRecord({
320
- leader: '',
321
- fields: [{
322
- tag: '242',
323
- ind1: ' ',
324
- ind2: ' ',
325
- subfields: [{
326
- code: 'a',
327
- value: 'World of art.'
328
- }]
329
- }]
330
- });
331
- it('Finds record valid - Punc $a', async () => {
332
- const validator = await (0, _endingPunctuation.default)();
333
- const result = await validator.validate(recordValidOnlyA);
334
- expect(result.valid).to.eql(true);
335
- });
336
- it('Finds record valid - Punc $p', async () => {
337
- const validator = await (0, _endingPunctuation.default)();
338
- const result = await validator.validate(recordValidMultiple);
339
- expect(result.valid).to.eql(true);
340
- });
341
- it('Finds record valid - Punc $a without $y', async () => {
342
- const validator = await (0, _endingPunctuation.default)();
343
- const result = await validator.validate(recordValidWithoutY);
344
- expect(result.valid).to.eql(true);
345
- });
346
-
347
- // Invalid tests
348
- const recordInvalidOnlyAMissingA = new _marcRecord.MarcRecord({
349
- leader: '',
350
- fields: [{
351
- tag: '242',
352
- ind1: ' ',
353
- ind2: ' ',
354
- subfields: [{
355
- code: 'a',
356
- value: 'World of art'
357
- }, {
358
- code: 'y',
359
- value: 'eng'
360
- }]
361
- }]
362
- });
363
- const recordInvalidOnlyAPuncY = new _marcRecord.MarcRecord({
364
- leader: '',
365
- fields: [{
366
- tag: '242',
367
- ind1: ' ',
368
- ind2: ' ',
369
- subfields: [{
370
- code: 'a',
371
- value: 'World of art.'
372
- }, {
373
- code: 'y',
374
- value: 'eng.'
375
- } // $y is also checked as rule is explicit
376
- ]
377
- }]
378
- });
379
- const recordInvalidOnlyAMissingAPuncY = new _marcRecord.MarcRecord({
380
- leader: '',
381
- fields: [{
382
- tag: '242',
383
- ind1: ' ',
384
- ind2: ' ',
385
- subfields: [{
386
- code: 'a',
387
- value: 'World of art'
388
- }, {
389
- code: 'y',
390
- value: 'eng.'
391
- } // $y is also checked as rule is explicit
392
- ]
393
- }]
394
- });
395
- const recordValidMultipleMissingP = new _marcRecord.MarcRecord({
396
- leader: '',
397
- fields: [{
398
- tag: '242',
399
- ind1: ' ',
400
- ind2: ' ',
401
- subfields: [{
402
- code: 'a',
403
- value: 'Annals of chemistry.'
404
- }, {
405
- code: 'n',
406
- value: 'Series C,'
407
- }, {
408
- code: 'p',
409
- value: 'Organic chemistry and biochemistry'
410
- }, {
411
- code: 'y',
412
- value: 'eng'
413
- }]
414
- }]
415
- });
416
-
417
- // "Suositellaan käytettäväksi myös osakenttää ‡y (käännöksen kielikoodi)." https://www.kiwi.fi/pages/viewpage.action?pageId=51282044
418
- const recordValidWithoutYMissingA = new _marcRecord.MarcRecord({
419
- leader: '',
420
- fields: [{
421
- tag: '242',
422
- ind1: ' ',
423
- ind2: ' ',
424
- subfields: [{
425
- code: 'a',
426
- value: 'World of art'
427
- }]
428
- }]
429
- });
430
- it('Finds record invalid - No punc at $a (only before $y)', async () => {
431
- const validator = await (0, _endingPunctuation.default)();
432
- const result = await validator.validate(recordInvalidOnlyAMissingA);
433
- expect(result).to.eql({
434
- message: ['Field 242 has invalid ending punctuation'],
435
- valid: false
436
- });
437
- });
438
- it('Finds record invalid - Punc at $y (Language field)', async () => {
439
- // $y is also checked as rule is explicit
440
- const validator = await (0, _endingPunctuation.default)();
441
- const result = await validator.validate(recordInvalidOnlyAPuncY);
442
- expect(result).to.eql({
443
- message: ['Field 242 has invalid ending punctuation'],
444
- valid: false
445
- });
446
- });
447
- it('Finds record invalid - No punc at $a & punc $y', async () => {
448
- // $y is also checked as rule is explicit
449
- const validator = await (0, _endingPunctuation.default)();
450
- const result = await validator.validate(recordInvalidOnlyAMissingAPuncY);
451
- expect(result).to.eql({
452
- message: ['Field 242 has invalid ending punctuation', 'Field 242 has invalid ending punctuation'],
453
- valid: false
454
- });
455
- });
456
- it('Finds record invalid - No punc $p (last before $y)', async () => {
457
- const validator = await (0, _endingPunctuation.default)();
458
- const result = await validator.validate(recordValidMultipleMissingP);
459
- expect(result).to.eql({
460
- message: ['Field 242 has invalid ending punctuation'],
461
- valid: false
462
- });
463
- });
464
- it('Finds record invalid - No punc $a (only)', async () => {
465
- const validator = await (0, _endingPunctuation.default)();
466
- const result = await validator.validate(recordValidWithoutYMissingA);
467
- expect(result).to.eql({
468
- message: ['Field 242 has invalid ending punctuation'],
469
- valid: false
470
- });
471
- });
472
-
473
- // Fix tests; invalid->valid
474
- it('Repairs the invalid record - Add punc $a', async () => {
475
- const validator = await (0, _endingPunctuation.default)();
476
- const result = await validator.fix(recordInvalidOnlyAMissingA);
477
- expect(recordInvalidOnlyAMissingA.equalsTo(recordValidOnlyA)).to.eql(true);
478
- expect(result).to.eql({
479
- message: ['Field 242 has invalid ending punctuation'],
480
- fix: ['Field 242 - Added punctuation to $a'],
481
- valid: false
482
- });
483
- });
484
- it('Repairs the invalid record - Remove punc $y (Language field)', async () => {
485
- const validator = await (0, _endingPunctuation.default)();
486
- const result = await validator.fix(recordInvalidOnlyAPuncY);
487
- expect(recordInvalidOnlyAPuncY.equalsTo(recordValidOnlyA)).to.eql(true);
488
- expect(result).to.eql({
489
- message: ['Field 242 has invalid ending punctuation'],
490
- fix: ['Field 242 - Removed punctuation from $y'],
491
- valid: false
492
- });
493
- });
494
- it('Repairs the invalid record - Add punc $a & remove punc $y (Language field)', async () => {
495
- const validator = await (0, _endingPunctuation.default)();
496
- const result = await validator.fix(recordInvalidOnlyAMissingAPuncY);
497
- expect(recordInvalidOnlyAMissingAPuncY.equalsTo(recordValidOnlyA)).to.eql(true);
498
- expect(result).to.eql({
499
- message: ['Field 242 has invalid ending punctuation', 'Field 242 has invalid ending punctuation'],
500
- fix: ['Field 242 - Removed punctuation from $y', 'Field 242 - Added punctuation to $a'],
501
- valid: false
502
- });
503
- });
504
- it('Repairs the invalid record - Add punc $p', async () => {
505
- const validator = await (0, _endingPunctuation.default)();
506
- const result = await validator.fix(recordValidMultipleMissingP);
507
- expect(recordValidMultipleMissingP.equalsTo(recordValidMultiple)).to.eql(true);
508
- expect(result).to.eql({
509
- message: ['Field 242 has invalid ending punctuation'],
510
- fix: ['Field 242 - Added punctuation to $p'],
511
- valid: false
512
- });
513
- });
514
- it('Repairs the invalid record - Add punc $a', async () => {
515
- const validator = await (0, _endingPunctuation.default)();
516
- const result = await validator.fix(recordValidWithoutYMissingA);
517
- expect(recordValidWithoutYMissingA.equalsTo(recordValidWithoutY)).to.eql(true);
518
- expect(result).to.eql({
519
- message: ['Field 242 has invalid ending punctuation'],
520
- fix: ['Field 242 - Added punctuation to $a'],
521
- valid: false
522
- });
523
- });
524
- });
525
-
526
- // "260 KYLLÄ Pääsääntö: $a : $b, $c. Tarkista eri poikkeukset ja välimerkitys MARC 21 Full -versiosta"
527
- // Punc only if last subfield c
528
- describe('#260 TRUE - Punc only if last subfield c', () => {
529
- // Valid tests
530
- const recordValidEndC = new _marcRecord.MarcRecord({
531
- leader: '',
532
- fields: [{
533
- tag: '260',
534
- ind1: ' ',
535
- ind2: ' ',
536
- subfields: [{
537
- code: 'a',
538
- value: 'Helsinki'
539
- }, {
540
- code: 'b',
541
- value: 'Suomen atk-kustannus,'
542
- }, {
543
- code: 'c',
544
- value: '1982.'
545
- }]
546
- }]
547
- });
548
- const recordValidEndG = new _marcRecord.MarcRecord({
549
- leader: '',
550
- fields: [{
551
- tag: '260',
552
- ind1: ' ',
553
- ind2: ' ',
554
- subfields: [{
555
- code: 'a',
556
- value: 'London'
557
- }, {
558
- code: 'b',
559
- value: 'Macmillan,'
560
- }, {
561
- code: 'c',
562
- value: '1971'
563
- }, {
564
- code: 'g',
565
- value: '(1973 printing)'
566
- }]
567
- }]
568
- });
569
- const recordValidEndB = new _marcRecord.MarcRecord({
570
- leader: '',
571
- fields: [{
572
- tag: '260',
573
- ind1: ' ',
574
- ind2: ' ',
575
- subfields: [{
576
- code: '3',
577
- value: 'June 1993-'
578
- }, {
579
- code: 'a',
580
- value: 'London'
581
- }, {
582
- code: 'b',
583
- value: 'Elle'
584
- }]
585
- }]
586
- });
587
- it('Finds record valid - Punc $c', async () => {
588
- const validator = await (0, _endingPunctuation.default)();
589
- const result = await validator.validate(recordValidEndC);
590
- expect(result.valid).to.eql(true);
591
- });
592
- it('Finds record valid - Punc char $g (after $c)', async () => {
593
- const validator = await (0, _endingPunctuation.default)();
594
- const result = await validator.validate(recordValidEndG);
595
- expect(result.valid).to.eql(true);
596
- });
597
- it('Finds record valid - No punc $b', async () => {
598
- const validator = await (0, _endingPunctuation.default)();
599
- const result = await validator.validate(recordValidEndB);
600
- expect(result.valid).to.eql(true);
601
- });
602
-
603
- // Invalid tests
604
- const recordInvalidEndC = new _marcRecord.MarcRecord({
605
- leader: '',
606
- fields: [{
607
- tag: '260',
608
- ind1: ' ',
609
- ind2: ' ',
610
- subfields: [{
611
- code: 'a',
612
- value: 'Helsinki'
613
- }, {
614
- code: 'b',
615
- value: 'Suomen atk-kustannus,'
616
- }, {
617
- code: 'c',
618
- value: '1982'
619
- }]
620
- }]
621
- });
622
- const recordInvalidEndGDouble = new _marcRecord.MarcRecord({
623
- leader: '',
624
- fields: [{
625
- tag: '260',
626
- ind1: ' ',
627
- ind2: ' ',
628
- subfields: [{
629
- code: 'a',
630
- value: 'London'
631
- }, {
632
- code: 'b',
633
- value: 'Macmillan,'
634
- }, {
635
- code: 'c',
636
- value: '1971'
637
- }, {
638
- code: 'g',
639
- value: '(1973 printing).'
640
- }]
641
- }]
642
- });
643
- it('Finds record invalid', async () => {
644
- const validator = await (0, _endingPunctuation.default)();
645
- const result = await validator.validate(recordInvalidEndC);
646
- expect(result).to.eql({
647
- message: ['Field 260 has invalid ending punctuation'],
648
- valid: false
649
- });
650
- });
651
- it('Finds record invalid', async () => {
652
- const validator = await (0, _endingPunctuation.default)();
653
- const result = await validator.validate(recordInvalidEndGDouble);
654
- expect(result).to.eql({
655
- message: ['Field 260 has invalid ending punctuation'],
656
- valid: false
657
- });
658
- });
659
-
660
- // Fix tests; invalid->valid
661
- it('Repairs the invalid record - Add punc $c', async () => {
662
- const validator = await (0, _endingPunctuation.default)();
663
- const result = await validator.fix(recordInvalidEndC);
664
- expect(recordInvalidEndC.equalsTo(recordValidEndC)).to.eql(true);
665
- expect(result).to.eql({
666
- message: ['Field 260 has invalid ending punctuation'],
667
- fix: ['Field 260 - Added punctuation to $c'],
668
- valid: false
669
- });
670
- });
671
- it('Repairs the invalid record - Remove double punc $g', async () => {
672
- const validator = await (0, _endingPunctuation.default)();
673
- const result = await validator.fix(recordInvalidEndGDouble);
674
- expect(recordInvalidEndGDouble.equalsTo(recordValidEndG)).to.eql(true);
675
- expect(result).to.eql({
676
- message: ['Field 260 has invalid ending punctuation'],
677
- fix: ['Field 260 - Removed double punctuation from $g'],
678
- valid: false
679
- });
680
- });
681
- });
682
-
683
- // 264-kenttään tulee loppupiste, JOS on käytetty osakenttää ‡c tuotantoajan, julkaisuajan,
684
- // jakeluajan tai valmistusajan ilmaisemiseen (2. indikaattori = 0, 1, 2 tai 3) JA osakenttä ‡c
685
- // ei pääty hakasulkuun ']' tai tavuviivaan '-' tai kaarisulkuun ')' tai kysymysmerkkiin '?'
686
-
687
- // Copyright-vuoden kanssa ei käytetä loppupistettä (2. indikaattori = 4).
688
-
689
- // Esimerkit
690
- // 264 #0 ‡a [Vantaa?] : ‡b [Olli Kela], ‡c [2011?]
691
- // 264 #1 ‡a Helsinki : ‡b Helsingin yliopisto, ‡c 1992-
692
- // 264 #1 ‡a Helsinki : ‡b Helsingin yliopisto, ‡c 1995-2006. ← loppupiste
693
- // 264 #2 ‡a Kouvola : ‡b Nuorisovirasto
694
- // 264 #3 ‡a Lahti : ‡b Valtion monistuskeskus, ‡c 1965. ← loppupiste
695
- describe('#264 TRUE - If ind2 === 0, 1, 2 or 3, punc at the end', () => {
696
- // Valid tests
697
- const recordValidInd2v1 = new _marcRecord.MarcRecord({
698
- leader: '',
699
- fields: [{
700
- tag: '264',
701
- ind1: '#',
702
- ind2: '1',
703
- subfields: [{
704
- code: 'a',
705
- value: 'Helsinki'
706
- }, {
707
- code: 'b',
708
- value: 'Helsingin yliopisto'
709
- }, {
710
- code: 'c',
711
- value: '1995-2006.'
712
- }]
713
- }]
714
- });
715
- const recordValidInd2v1Short = new _marcRecord.MarcRecord({
716
- leader: '',
717
- fields: [{
718
- tag: '264',
719
- ind1: '#',
720
- ind2: '1',
721
- subfields: [{
722
- code: 'a',
723
- value: 'Helsinki'
724
- }, {
725
- code: 'b',
726
- value: 'Helsingin yliopisto'
727
- }, {
728
- code: 'c',
729
- value: '1995-'
730
- }]
731
- }]
732
- });
733
- const recordValidInd2v2WithoutC = new _marcRecord.MarcRecord({
734
- leader: '',
735
- fields: [{
736
- tag: '264',
737
- ind1: '#',
738
- ind2: '2',
739
- subfields: [{
740
- code: 'a',
741
- value: 'Kouvola'
742
- }, {
743
- code: 'b',
744
- value: 'Nuorisovirasto'
745
- }]
746
- }]
747
- });
748
- const recordValidCopyright = new _marcRecord.MarcRecord({
749
- leader: '',
750
- fields: [{
751
- tag: '264',
752
- ind1: ' ',
753
- ind2: '4',
754
- subfields: [{
755
- code: 'a',
756
- value: 'Helsinki : '
757
- }, {
758
- code: 'b',
759
- value: 'Suomen poliisikoirayhdistys.'
760
- }, {
761
- code: 'c',
762
- value: '© 1974'
763
- }]
764
- }]
765
- });
766
- it('Finds record valid - Ind2 = 1, $c 1995-2006.', async () => {
767
- const validator = await (0, _endingPunctuation.default)();
768
- const result = await validator.validate(recordValidInd2v1);
769
- expect(result.valid).to.eql(true);
770
- });
771
- it('Finds record valid - Ind2 = 1, $c 1995-', async () => {
772
- const validator = await (0, _endingPunctuation.default)();
773
- const result = await validator.validate(recordValidInd2v1Short);
774
- expect(result.valid).to.eql(true);
775
- });
776
- it('Finds record valid - Ind2 = 2, no $c', async () => {
777
- const validator = await (0, _endingPunctuation.default)();
778
- const result = await validator.validate(recordValidInd2v2WithoutC);
779
- expect(result.valid).to.eql(true);
780
- });
781
- it('Finds record valid - Ind2 = 4, copyright', async () => {
782
- const validator = await (0, _endingPunctuation.default)();
783
- const result = await validator.validate(recordValidCopyright);
784
- expect(result.valid).to.eql(true);
785
- });
786
- const recordInvalidInd2v1 = new _marcRecord.MarcRecord({
787
- leader: '',
788
- fields: [{
789
- tag: '264',
790
- ind1: '#',
791
- ind2: '1',
792
- subfields: [{
793
- code: 'a',
794
- value: 'Helsinki'
795
- }, {
796
- code: 'b',
797
- value: 'Helsingin yliopisto'
798
- }, {
799
- code: 'c',
800
- value: '1995-2006'
801
- }]
802
- }]
803
- });
804
- const recordInvalidCopyrightCExtra = new _marcRecord.MarcRecord({
805
- leader: '',
806
- fields: [{
807
- tag: '264',
808
- ind1: ' ',
809
- ind2: '4',
810
- subfields: [{
811
- code: 'a',
812
- value: 'Helsinki : '
813
- }, {
814
- code: 'b',
815
- value: 'Suomen poliisikoirayhdistys.'
816
- }, {
817
- code: 'c',
818
- value: '© 1974.'
819
- }]
820
- }]
821
- });
822
- it('Finds record invalid - No punc $c', async () => {
823
- const validator = await (0, _endingPunctuation.default)();
824
- const result = await validator.validate(recordInvalidInd2v1);
825
- expect(result).to.eql({
826
- message: ['Field 264 has invalid ending punctuation'],
827
- valid: false
828
- });
829
- });
830
- it('Finds record invalid - Ind2 = 4, copyright, extra punc $c', async () => {
831
- const validator = await (0, _endingPunctuation.default)();
832
- const result = await validator.validate(recordInvalidCopyrightCExtra);
833
- expect(result).to.eql({
834
- message: ['Field 264 has invalid ending punctuation'],
835
- valid: false
836
- });
837
- });
838
-
839
- // Fix tests; invalid->valid
840
- it('Repairs the invalid record - Add punc $c', async () => {
841
- const validator = await (0, _endingPunctuation.default)();
842
- const result = await validator.fix(recordInvalidInd2v1);
843
- expect(recordInvalidInd2v1.equalsTo(recordValidInd2v1)).to.eql(true);
844
- expect(result).to.eql({
845
- message: ['Field 264 has invalid ending punctuation'],
846
- fix: ['Field 264 - Added punctuation to $c'],
847
- valid: false
848
- });
849
- });
850
- it('Repairs the invalid record - Remove punc $c ($c has ©, should not have punc)', async () => {
851
- const validator = await (0, _endingPunctuation.default)();
852
- const result = await validator.fix(recordInvalidCopyrightCExtra);
853
- expect(recordInvalidCopyrightCExtra.equalsTo(recordValidCopyright)).to.eql(true);
854
- expect(result).to.eql({
855
- message: ['Field 264 has invalid ending punctuation'],
856
- fix: ['Field 264 - Removed punctuation from $c'],
857
- valid: false
858
- });
859
- });
860
- });
861
-
862
- // "340 KYLLÄ Vain joidenkin osakenttien jälkeen. Tarkista osakentät MARC 21 Full -versiosta
863
- // -b: Piste aina osakentän loppuun
864
- // - a, d, e, f, h, i: Piste näistä viimeisen osakentän loppuun"
865
- // This doesn't match spec at all, but these rules were provided (https://www.kansalliskirjasto.fi/extra/marc21/bib/3XX.htm#340)
866
- describe('#340 TRUE - Punc at $b always and to last of [$a, $d, $e, $f, $h, $i]', () => {
867
- // Valid tests
868
- const recordValidA = new _marcRecord.MarcRecord({
869
- leader: '',
870
- fields: [{
871
- tag: '340',
872
- ind1: ' ',
873
- ind2: ' ',
874
- subfields: [{
875
- code: 'a',
876
- value: 'marble.'
877
- }]
878
- }]
879
- });
880
- const recordValidAB = new _marcRecord.MarcRecord({
881
- leader: '',
882
- fields: [{
883
- tag: '340',
884
- ind1: ' ',
885
- ind2: ' ',
886
- subfields: [{
887
- code: 'a',
888
- value: 'parchment.'
889
- },
890
- // This punc doesn't match example: https://www.kansalliskirjasto.fi/extra/marc21/bib/3XX.htm#340
891
- {
892
- code: 'b',
893
- value: '20 cm. folded to 10 x 12 cm.'
894
- }]
895
- }]
896
- });
897
- const recordValidDD = new _marcRecord.MarcRecord({
898
- leader: '',
899
- fields: [{
900
- tag: '340',
901
- ind1: ' ',
902
- ind2: ' ',
903
- subfields: [{
904
- code: 'd',
905
- value: 'handwritten'
906
- }, {
907
- code: 'd',
908
- value: 'typed.'
909
- }]
910
- }]
911
- });
912
- const recordValidComplex = new _marcRecord.MarcRecord({
913
- leader: '',
914
- fields: [{
915
- tag: '340',
916
- ind1: ' ',
917
- ind2: ' ',
918
- subfields: [{
919
- code: 'a',
920
- value: 'wove paper'
921
- }, {
922
- code: 'c',
923
- value: 'ink'
924
- }, {
925
- code: 'c',
926
- value: 'gouache'
927
- }, {
928
- code: 'd',
929
- value: 'lithography'
930
- }, {
931
- code: 'd',
932
- value: 'collage.'
933
- },
934
- // This punc doesn't match example: https://www.kansalliskirjasto.fi/extra/marc21/bib/3XX.htm#340
935
- {
936
- code: 'g',
937
- value: 'polychrome'
938
- }]
939
- }]
940
- });
941
- const recordValidJ2 = new _marcRecord.MarcRecord({
942
- leader: '',
943
- fields: [{
944
- tag: '340',
945
- ind1: ' ',
946
- ind2: ' ',
947
- subfields: [{
948
- code: 'j',
949
- value: 'original'
950
- }, {
951
- code: '2',
952
- value: 'rda'
953
- }]
954
- }]
955
- });
956
- it('Finds record valid - Punc $a (only)', async () => {
957
- const validator = await (0, _endingPunctuation.default)();
958
- const result = await validator.validate(recordValidA);
959
- expect(result.valid).to.eql(true);
960
- });
961
- it('Finds record valid - Punc $a (last) & punc $b (mandatory)', async () => {
962
- const validator = await (0, _endingPunctuation.default)();
963
- const result = await validator.validate(recordValidAB);
964
- expect(result.valid).to.eql(true);
965
- });
966
- it('Finds record valid - Punc $d (last of two)', async () => {
967
- const validator = await (0, _endingPunctuation.default)();
968
- const result = await validator.validate(recordValidDD);
969
- expect(result.valid).to.eql(true);
970
- });
971
- it('Finds record valid - Punc $d (last of two) followed by $g', async () => {
972
- const validator = await (0, _endingPunctuation.default)();
973
- const result = await validator.validate(recordValidComplex);
974
- expect(result.valid).to.eql(true);
975
- });
976
- it('Finds record valid - No punc (not $b, nor from list)', async () => {
977
- const validator = await (0, _endingPunctuation.default)();
978
- const result = await validator.validate(recordValidJ2);
979
- expect(result.valid).to.eql(true);
980
- });
981
-
982
- // Invalid tests
983
- const recordInvalidA = new _marcRecord.MarcRecord({
984
- leader: '',
985
- fields: [{
986
- tag: '340',
987
- ind1: ' ',
988
- ind2: ' ',
989
- subfields: [{
990
- code: 'a',
991
- value: 'marble'
992
- }]
993
- }]
994
- });
995
- const recordInvalidAMissingB = new _marcRecord.MarcRecord({
996
- leader: '',
997
- fields: [{
998
- tag: '340',
999
- ind1: ' ',
1000
- ind2: ' ',
1001
- subfields: [{
1002
- code: 'a',
1003
- value: 'parchment'
1004
- },
1005
- // This punc doesn't match example: https://www.kansalliskirjasto.fi/extra/marc21/bib/3XX.htm#340
1006
- {
1007
- code: 'b',
1008
- value: '20 cm. folded to 10 x 12 cm.'
1009
- }]
1010
- }]
1011
- });
1012
- const recordInvalidABMissing = new _marcRecord.MarcRecord({
1013
- leader: '',
1014
- fields: [{
1015
- tag: '340',
1016
- ind1: ' ',
1017
- ind2: ' ',
1018
- subfields: [{
1019
- code: 'a',
1020
- value: 'parchment.'
1021
- },
1022
- // This punc doesn't match example: https://www.kansalliskirjasto.fi/extra/marc21/bib/3XX.htm#340
1023
- {
1024
- code: 'b',
1025
- value: '20 cm. folded to 10 x 12 cm'
1026
- }]
1027
- }]
1028
- });
1029
- const recordInvalidDDMissing = new _marcRecord.MarcRecord({
1030
- leader: '',
1031
- fields: [{
1032
- tag: '340',
1033
- ind1: ' ',
1034
- ind2: ' ',
1035
- subfields: [{
1036
- code: 'd',
1037
- value: 'handwritten'
1038
- }, {
1039
- code: 'd',
1040
- value: 'typed'
1041
- }]
1042
- }]
1043
- });
1044
- const recordInvalidComplexDMissing = new _marcRecord.MarcRecord({
1045
- leader: '',
1046
- fields: [{
1047
- tag: '340',
1048
- ind1: ' ',
1049
- ind2: ' ',
1050
- subfields: [{
1051
- code: 'a',
1052
- value: 'wove paper'
1053
- }, {
1054
- code: 'c',
1055
- value: 'ink'
1056
- }, {
1057
- code: 'c',
1058
- value: 'gouache'
1059
- }, {
1060
- code: 'd',
1061
- value: 'lithography'
1062
- }, {
1063
- code: 'd',
1064
- value: 'collage'
1065
- },
1066
- // This punc doesn't match example: https://www.kansalliskirjasto.fi/extra/marc21/bib/3XX.htm#340
1067
- {
1068
- code: 'g',
1069
- value: 'polychrome'
1070
- }]
1071
- }]
1072
- });
1073
- it('Finds record invalid - No punc $a (only)', async () => {
1074
- const validator = await (0, _endingPunctuation.default)();
1075
- const result = await validator.validate(recordInvalidA);
1076
- expect(result).to.eql({
1077
- message: ['Field 340 has invalid ending punctuation'],
1078
- valid: false
1079
- });
1080
- });
1081
- it('Finds record invalid - No punc $a (last)', async () => {
1082
- const validator = await (0, _endingPunctuation.default)();
1083
- const result = await validator.validate(recordInvalidAMissingB);
1084
- expect(result).to.eql({
1085
- message: ['Field 340 has invalid ending punctuation'],
1086
- valid: false
1087
- });
1088
- });
1089
- it('Finds record invalid - No punc $b (mandatory)', async () => {
1090
- const validator = await (0, _endingPunctuation.default)();
1091
- const result = await validator.validate(recordInvalidABMissing);
1092
- expect(result).to.eql({
1093
- message: ['Field 340 has invalid ending punctuation'],
1094
- valid: false
1095
- });
1096
- });
1097
- it('Finds record invalid - No punc $d (last of two)', async () => {
1098
- const validator = await (0, _endingPunctuation.default)();
1099
- const result = await validator.validate(recordInvalidDDMissing);
1100
- expect(result).to.eql({
1101
- message: ['Field 340 has invalid ending punctuation'],
1102
- valid: false
1103
- });
1104
- });
1105
- it('Finds record invalid - No punc $d (last of two) followed by $g', async () => {
1106
- const validator = await (0, _endingPunctuation.default)();
1107
- const result = await validator.validate(recordInvalidComplexDMissing);
1108
- expect(result).to.eql({
1109
- message: ['Field 340 has invalid ending punctuation'],
1110
- valid: false
1111
- });
1112
- });
1113
-
1114
- // Fix tests; invalid->valid
1115
- it('Repairs the invalid record - Add punc $a (only)', async () => {
1116
- const validator = await (0, _endingPunctuation.default)();
1117
- const result = await validator.fix(recordInvalidA);
1118
- expect(recordInvalidA.equalsTo(recordInvalidA)).to.eql(true);
1119
- expect(result).to.eql({
1120
- message: ['Field 340 has invalid ending punctuation'],
1121
- fix: ['Field 340 - Added punctuation to $a'],
1122
- valid: false
1123
- });
1124
- });
1125
- it('Repairs the invalid record - Add punc $a (last)', async () => {
1126
- const validator = await (0, _endingPunctuation.default)();
1127
- const result = await validator.fix(recordInvalidAMissingB);
1128
- expect(recordInvalidAMissingB.equalsTo(recordValidAB)).to.eql(true);
1129
- expect(result).to.eql({
1130
- message: ['Field 340 has invalid ending punctuation'],
1131
- fix: ['Field 340 - Added punctuation to $a'],
1132
- valid: false
1133
- });
1134
- });
1135
- it('Repairs the invalid record - Add punc $b (mandatory)', async () => {
1136
- const validator = await (0, _endingPunctuation.default)();
1137
- const result = await validator.fix(recordInvalidABMissing);
1138
- expect(recordInvalidABMissing.equalsTo(recordValidAB)).to.eql(true);
1139
- expect(result).to.eql({
1140
- message: ['Field 340 has invalid ending punctuation'],
1141
- fix: ['Field 340 - Added punctuation to $b'],
1142
- valid: false
1143
- });
1144
- });
1145
- it('Repairs the invalid record - Add punc $d (last of two)', async () => {
1146
- const validator = await (0, _endingPunctuation.default)();
1147
- const result = await validator.fix(recordInvalidDDMissing);
1148
- expect(recordInvalidDDMissing.equalsTo(recordValidDD)).to.eql(true);
1149
- expect(result).to.eql({
1150
- message: ['Field 340 has invalid ending punctuation'],
1151
- fix: ['Field 340 - Added punctuation to $d'],
1152
- valid: false
1153
- });
1154
- });
1155
- it('Repairs the invalid record - Add punc $d (last of list)', async () => {
1156
- const validator = await (0, _endingPunctuation.default)();
1157
- const result = await validator.fix(recordInvalidComplexDMissing);
1158
- expect(recordInvalidComplexDMissing.equalsTo(recordInvalidComplexDMissing)).to.eql(true);
1159
- expect(result).to.eql({
1160
- message: ['Field 340 has invalid ending punctuation'],
1161
- fix: ['Field 340 - Added punctuation to $d'],
1162
- valid: false
1163
- });
1164
- });
1165
- });
1166
-
1167
- // "520 KYLLÄ Jos viimeinen osakenttä on $u, piste on ennen sitä" (Sama kuin 242, $y)
1168
- describe('#520 TRUE - If last subfield $u, punc before it', () => {
1169
- // Valid tests
1170
- const recordValid = new _marcRecord.MarcRecord({
1171
- leader: '',
1172
- fields: [{
1173
- tag: '520',
1174
- ind1: ' ',
1175
- ind2: ' ',
1176
- subfields: [{
1177
- code: 'a',
1178
- value: 'Mediaväkivalta ja sen yleisö.'
1179
- }]
1180
- }]
1181
- });
1182
- const recordValidWithU = new _marcRecord.MarcRecord({
1183
- leader: '',
1184
- fields: [{
1185
- tag: '520',
1186
- ind1: ' ',
1187
- ind2: ' ',
1188
- subfields: [{
1189
- code: 'a',
1190
- value: 'Abstrakti.'
1191
- },
1192
- // This does not match example: https://www.kansalliskirjasto.fi/extra/marc21/bib/50X-53X.htm#520
1193
- {
1194
- code: 'u',
1195
- value: 'http://www.ojp.usdoj.gov/bjs/abstract/cchrie98.htm'
1196
- }]
1197
- }]
1198
- });
1199
- const recordValidU = new _marcRecord.MarcRecord({
1200
- leader: '',
1201
- fields: [{
1202
- tag: '520',
1203
- ind1: ' ',
1204
- ind2: ' ',
1205
- subfields: [{
1206
- code: 'a',
1207
- value: 'Abstrakti.'
1208
- },
1209
- // This does not match example: https://www.kansalliskirjasto.fi/extra/marc21/bib/50X-53X.htm#520
1210
- {
1211
- code: 'u',
1212
- value: 'http://www.ojp.usdoj.gov/bjs/abstract/cchrie98.htm.'
1213
- }]
1214
- }]
1215
- });
1216
- it('Finds record valid - Punc $a (without $u)', async () => {
1217
- const validator = await (0, _endingPunctuation.default)();
1218
- const result = await validator.validate(recordValid);
1219
- expect(result.valid).to.eql(true);
1220
- });
1221
- it('Finds record valid - Punc $a (with $u) ', async () => {
1222
- const validator = await (0, _endingPunctuation.default)();
1223
- const result = await validator.validate(recordValidWithU);
1224
- expect(result.valid).to.eql(true);
1225
- });
1226
- it('Finds record valid - Punc $a & $u (punc at $u should be ignored) ', async () => {
1227
- const validator = await (0, _endingPunctuation.default)();
1228
- const result = await validator.validate(recordValidU);
1229
- expect(result.valid).to.eql(true);
1230
- });
1231
-
1232
- // Invalid tests
1233
- const recordInvalid = new _marcRecord.MarcRecord({
1234
- leader: '',
1235
- fields: [{
1236
- tag: '520',
1237
- ind1: ' ',
1238
- ind2: ' ',
1239
- subfields: [{
1240
- code: 'a',
1241
- value: 'Mediaväkivalta ja sen yleisö'
1242
- }]
1243
- }]
1244
- });
1245
- const recordInvalidWithU = new _marcRecord.MarcRecord({
1246
- leader: '',
1247
- fields: [{
1248
- tag: '520',
1249
- ind1: ' ',
1250
- ind2: ' ',
1251
- subfields: [{
1252
- code: 'a',
1253
- value: 'Abstrakti'
1254
- }, {
1255
- code: 'u',
1256
- value: 'http://www.ojp.usdoj.gov/bjs/abstract/cchrie98.htm'
1257
- }]
1258
- }]
1259
- });
1260
- it('Finds record invalid - No punc $a (without $u)', async () => {
1261
- const validator = await (0, _endingPunctuation.default)();
1262
- const result = await validator.validate(recordInvalid);
1263
- expect(result).to.eql({
1264
- message: ['Field 520 has invalid ending punctuation'],
1265
- valid: false
1266
- });
1267
- });
1268
- it('Finds record invalid - No punc $a (with $u)', async () => {
1269
- const validator = await (0, _endingPunctuation.default)();
1270
- const result = await validator.validate(recordInvalidWithU);
1271
- expect(result).to.eql({
1272
- message: ['Field 520 has invalid ending punctuation'],
1273
- valid: false
1274
- });
1275
- });
1276
-
1277
- // Fix tests; invalid->valid
1278
- it('Repairs the invalid record - Add punc $a (only)', async () => {
1279
- const validator = await (0, _endingPunctuation.default)();
1280
- const result = await validator.fix(recordInvalid);
1281
- expect(recordInvalid.equalsTo(recordValid)).to.eql(true);
1282
- expect(result).to.eql({
1283
- message: ['Field 520 has invalid ending punctuation'],
1284
- fix: ['Field 520 - Added punctuation to $a'],
1285
- valid: false
1286
- });
1287
- });
1288
- it('Repairs the invalid record - Add punc $a (last before $u)', async () => {
1289
- const validator = await (0, _endingPunctuation.default)();
1290
- const result = await validator.fix(recordInvalidWithU);
1291
- expect(recordInvalidWithU.equalsTo(recordValidWithU)).to.eql(true);
1292
- expect(result).to.eql({
1293
- message: ['Field 520 has invalid ending punctuation'],
1294
- fix: ['Field 520 - Added punctuation to $a'],
1295
- valid: false
1296
- });
1297
- });
1298
- });
1299
-
1300
- // "538 KYLLÄ Jos viimeinen osakenttä on $u, piste on ennen sitä" (Sama kuin 520)
1301
- // Eli piste merkitään vikaan osakenttään as usual, mutta ennen *y*-osakenttää
1302
- // (speksin mukaan y->u) https://www.kansalliskirjasto.fi/extra/marc21/bib/53X-58X.htm#538
1303
- describe('#538 TRUE - If last subfield $u, punc before it', () => {
1304
- // Valid tests
1305
- const recordValid = new _marcRecord.MarcRecord({
1306
- leader: '',
1307
- fields: [{
1308
- tag: '538',
1309
- ind1: ' ',
1310
- ind2: ' ',
1311
- subfields: [{
1312
- code: 'a',
1313
- value: 'Project methodology for digital version'
1314
- }, {
1315
- code: 'i',
1316
- value: 'Technical details.'
1317
- },
1318
- // This ended to ':' in examples, but it doesn't match statet rules: https://www.kansalliskirjasto.fi/extra/marc21/bib/53X-58X.htm#538
1319
- {
1320
- code: 'u',
1321
- value: 'http://www.columbia.edu/dlc/linglung/methodology.html'
1322
- }]
1323
- }]
1324
- });
1325
- const recordValidPuncU = new _marcRecord.MarcRecord({
1326
- leader: '',
1327
- fields: [{
1328
- tag: '538',
1329
- ind1: ' ',
1330
- ind2: ' ',
1331
- subfields: [{
1332
- code: 'a',
1333
- value: 'Project methodology for digital version'
1334
- }, {
1335
- code: 'i',
1336
- value: 'Technical details.'
1337
- }, {
1338
- code: 'u',
1339
- value: 'http://www.columbia.edu/dlc/linglung/methodology.html.'
1340
- }]
1341
- }]
1342
- });
1343
- const recordValidOnlyA = new _marcRecord.MarcRecord({
1344
- leader: '',
1345
- fields: [{
1346
- tag: '538',
1347
- ind1: ' ',
1348
- ind2: ' ',
1349
- subfields: [{
1350
- code: 'a',
1351
- value: 'SECAM-videolaite.'
1352
- }]
1353
- }]
1354
- });
1355
- it('Finds record valid - Punc $i (last before $u)', async () => {
1356
- const validator = await (0, _endingPunctuation.default)();
1357
- const result = await validator.validate(recordValid);
1358
- expect(result.valid).to.eql(true);
1359
- });
1360
- it('Finds record valid - Punc $i & punc $u ($u is URL, should pass)', async () => {
1361
- const validator = await (0, _endingPunctuation.default)();
1362
- const result = await validator.validate(recordValidPuncU);
1363
- expect(result.valid).to.eql(true);
1364
- });
1365
- it('Finds record valid - Punc $a (only)', async () => {
1366
- const validator = await (0, _endingPunctuation.default)();
1367
- const result = await validator.validate(recordValidOnlyA);
1368
- expect(result.valid).to.eql(true);
1369
- });
1370
-
1371
- // Invalid tests
1372
- const recordInvalidMissingI = new _marcRecord.MarcRecord({
1373
- leader: '',
1374
- fields: [{
1375
- tag: '538',
1376
- ind1: ' ',
1377
- ind2: ' ',
1378
- subfields: [{
1379
- code: 'a',
1380
- value: 'Project methodology for digital version'
1381
- }, {
1382
- code: 'i',
1383
- value: 'Technical details'
1384
- }, {
1385
- code: 'u',
1386
- value: 'http://www.columbia.edu/dlc/linglung/methodology.html'
1387
- }]
1388
- }]
1389
- });
1390
- const recordInvalidI = new _marcRecord.MarcRecord({
1391
- leader: '',
1392
- fields: [{
1393
- tag: '538',
1394
- ind1: ' ',
1395
- ind2: ' ',
1396
- subfields: [{
1397
- code: 'a',
1398
- value: 'Project methodology for digital version'
1399
- }, {
1400
- code: 'i',
1401
- value: 'Technical details:'
1402
- },
1403
- // This is actually like in examples, but it doesn't match statet rules: https://www.kansalliskirjasto.fi/extra/marc21/bib/53X-58X.htm#538
1404
- {
1405
- code: 'u',
1406
- value: 'http://www.columbia.edu/dlc/linglung/methodology.html'
1407
- }]
1408
- }]
1409
- });
1410
- const recordInvalidOnlyA = new _marcRecord.MarcRecord({
1411
- leader: '',
1412
- fields: [{
1413
- tag: '538',
1414
- ind1: ' ',
1415
- ind2: ' ',
1416
- subfields: [{
1417
- code: 'a',
1418
- value: 'SECAM-videolaite'
1419
- }]
1420
- }]
1421
- });
1422
- it('Finds record invalid - No punc $i (last before $u)', async () => {
1423
- const validator = await (0, _endingPunctuation.default)();
1424
- const result = await validator.validate(recordInvalidMissingI);
1425
- expect(result).to.eql({
1426
- message: ['Field 538 has invalid ending punctuation'],
1427
- valid: false
1428
- });
1429
- });
1430
- it('Finds record invalid - Invalid punc $i (":" not valid punc mark, but this is according example...)', async () => {
1431
- const validator = await (0, _endingPunctuation.default)();
1432
- const result = await validator.validate(recordInvalidI);
1433
- expect(result).to.eql({
1434
- message: ['Field 538 has invalid ending punctuation'],
1435
- valid: false
1436
- });
1437
- });
1438
- it('Finds record invalid - No punc $a (only)', async () => {
1439
- const validator = await (0, _endingPunctuation.default)();
1440
- const result = await validator.validate(recordInvalidOnlyA);
1441
- expect(result).to.eql({
1442
- message: ['Field 538 has invalid ending punctuation'],
1443
- valid: false
1444
- });
1445
- });
1446
-
1447
- // Fix tests; invalid->valid
1448
- it('Repairs the invalid record - Add punc $i (last)', async () => {
1449
- const validator = await (0, _endingPunctuation.default)();
1450
- const result = await validator.fix(recordInvalidMissingI);
1451
- expect(recordInvalidMissingI.equalsTo(recordValid)).to.eql(true);
1452
- expect(result).to.eql({
1453
- message: ['Field 538 has invalid ending punctuation'],
1454
- fix: ['Field 538 - Added punctuation to $i'],
1455
- valid: false
1456
- });
1457
- });
1458
- it('Repairs the invalid record - Add punc $a (only)', async () => {
1459
- const validator = await (0, _endingPunctuation.default)();
1460
- const result = await validator.fix(recordInvalidOnlyA);
1461
- expect(recordInvalidOnlyA.equalsTo(recordValidOnlyA)).to.eql(true);
1462
- expect(result).to.eql({
1463
- message: ['Field 538 has invalid ending punctuation'],
1464
- fix: ['Field 538 - Added punctuation to $a'],
1465
- valid: false
1466
- });
1467
- });
1468
- });
1469
-
1470
- // "567 KYLLÄ osakentän $a jälkeen, EI muiden osakenttien jälkeen"
1471
- // Only if last subfield $a
1472
- describe('#567 TRUE - After subfield $a, FALSE after others', () => {
1473
- // Valid tests
1474
- const recordValid = new _marcRecord.MarcRecord({
1475
- leader: '',
1476
- fields: [{
1477
- tag: '567',
1478
- ind1: ' ',
1479
- ind2: ' ',
1480
- subfields: [{
1481
- code: 'a',
1482
- value: 'Narratiivinen tutkimus.'
1483
- }]
1484
- }]
1485
- });
1486
- const recordValidWithoutA = new _marcRecord.MarcRecord({
1487
- leader: '',
1488
- fields: [{
1489
- tag: '567',
1490
- ind1: ' ',
1491
- ind2: ' ',
1492
- subfields: [{
1493
- code: 'b',
1494
- value: 'Narrative inquiry'
1495
- }, {
1496
- code: '2',
1497
- value: 'lcsh'
1498
- }]
1499
- }]
1500
- });
1501
- it('Finds record valid - Punc $a (only)', async () => {
1502
- const validator = await (0, _endingPunctuation.default)();
1503
- const result = await validator.validate(recordValid);
1504
- expect(result.valid).to.eql(true);
1505
- });
1506
- it('Finds record valid - No punc $b (only data field)', async () => {
1507
- const validator = await (0, _endingPunctuation.default)();
1508
- const result = await validator.validate(recordValidWithoutA);
1509
- expect(result.valid).to.eql(true);
1510
- });
1511
-
1512
- // Invalid tests
1513
- const recordInvalid = new _marcRecord.MarcRecord({
1514
- leader: '',
1515
- fields: [{
1516
- tag: '567',
1517
- ind1: ' ',
1518
- ind2: ' ',
1519
- subfields: [{
1520
- code: 'a',
1521
- value: 'Narratiivinen tutkimus'
1522
- }]
1523
- }]
1524
- });
1525
- const recordInvalidWithoutA = new _marcRecord.MarcRecord({
1526
- leader: '',
1527
- fields: [{
1528
- tag: '567',
1529
- ind1: ' ',
1530
- ind2: ' ',
1531
- subfields: [{
1532
- code: 'b',
1533
- value: 'Narrative inquiry.'
1534
- }, {
1535
- code: '2',
1536
- value: 'lcsh'
1537
- }]
1538
- }]
1539
- });
1540
- it('Finds record invalid - No punc $a (only)', async () => {
1541
- const validator = await (0, _endingPunctuation.default)();
1542
- const result = await validator.validate(recordInvalid);
1543
- expect(result).to.eql({
1544
- message: ['Field 567 has invalid ending punctuation'],
1545
- valid: false
1546
- });
1547
- });
1548
- it('Finds record invalid - Punc $b (only data field)', async () => {
1549
- const validator = await (0, _endingPunctuation.default)();
1550
- const result = await validator.validate(recordInvalidWithoutA);
1551
- expect(result).to.eql({
1552
- message: ['Field 567 has invalid ending punctuation'],
1553
- valid: false
1554
- });
1555
- });
1556
-
1557
- // Fix tests; invalid->valid
1558
- it('Repairs the invalid record - Add punc $a (only)', async () => {
1559
- const validator = await (0, _endingPunctuation.default)();
1560
- const result = await validator.fix(recordInvalid);
1561
- expect(recordInvalid.equalsTo(recordValid)).to.eql(true);
1562
- expect(result).to.eql({
1563
- message: ['Field 567 has invalid ending punctuation'],
1564
- fix: ['Field 567 - Added punctuation to $a'],
1565
- valid: false
1566
- });
1567
- });
1568
- it('Repairs the invalid record - Remove punc $b (only data field)', async () => {
1569
- const validator = await (0, _endingPunctuation.default)();
1570
- const result = await validator.fix(recordInvalidWithoutA);
1571
- expect(recordInvalidWithoutA.equalsTo(recordValidWithoutA)).to.eql(true);
1572
- expect(result).to.eql({
1573
- message: ['Field 567 has invalid ending punctuation'],
1574
- fix: ['Field 567 - Removed punctuation from $b'],
1575
- valid: false
1576
- });
1577
- });
1578
- });
1579
-
1580
- // "647-651 EI - EI suomalaisten sanastojen termeihin, muihin sanaston käytännön mukaan, yleensä KYLLÄ"
1581
- // Finnish terms at $2:['ysa', 'yso', 'kassu', 'seko', 'valo', 'kulo', 'puho', 'oiko', 'mero', 'liito', 'fast', 'allars']
1582
- // Default TRUE, until more special cases are added
1583
- describe('#647-651 FALSE - If Finnish, else TRUE', () => {
1584
- // Valid tests
1585
- const recordValid647FastEndPunc = new _marcRecord.MarcRecord({
1586
- leader: '',
1587
- fields: [{
1588
- tag: '647',
1589
- ind1: ' ',
1590
- ind2: '7',
1591
- subfields: [{
1592
- code: 'a',
1593
- value: 'Hurricane Katrina'
1594
- }, {
1595
- code: 'd',
1596
- value: '(2005)'
1597
- }, {
1598
- code: '2',
1599
- value: 'fast'
1600
- }]
1601
- }]
1602
- });
1603
- const recordVali648dFinNo = new _marcRecord.MarcRecord({
1604
- leader: '',
1605
- fields: [{
1606
- tag: '648',
1607
- ind1: ' ',
1608
- ind2: '7',
1609
- subfields: [{
1610
- code: 'a',
1611
- value: '1900-luku'
1612
- }, {
1613
- code: '2',
1614
- value: 'yso/swe'
1615
- }]
1616
- }]
1617
- });
1618
- const recordValid648FastNo = new _marcRecord.MarcRecord({
1619
- leader: '',
1620
- fields: [{
1621
- tag: '648',
1622
- ind1: ' ',
1623
- ind2: '7',
1624
- subfields: [{
1625
- code: 'a',
1626
- value: '1862'
1627
- }, {
1628
- code: '2',
1629
- value: 'fast'
1630
- } // https://www.kansalliskirjasto.fi/extra/marc21/bib/6XX.htm#648
1631
- ]
1632
- }]
1633
- });
1634
- const recordValid650FinNo = new _marcRecord.MarcRecord({
1635
- leader: '',
1636
- fields: [{
1637
- tag: '650',
1638
- ind1: ' ',
1639
- ind2: '7',
1640
- subfields: [{
1641
- code: 'a',
1642
- value: 'kirjastot'
1643
- }, {
1644
- code: 'x',
1645
- value: 'atk-järjestelmät'
1646
- }, {
1647
- code: '2',
1648
- value: 'kauno/fin'
1649
- }]
1650
- }, {
1651
- tag: '650',
1652
- ind1: ' ',
1653
- ind2: '7',
1654
- subfields: [{
1655
- code: 'a',
1656
- value: 'ajovalot'
1657
- }, {
1658
- code: '2',
1659
- value: 'juho'
1660
- }]
1661
- }]
1662
- });
1663
- const recordValid650EngNoControl = new _marcRecord.MarcRecord({
1664
- leader: '',
1665
- fields: [{
1666
- tag: '650',
1667
- ind1: ' ',
1668
- ind2: ' ',
1669
- subfields: [{
1670
- code: 'a',
1671
- value: 'Flour industry'
1672
- }, {
1673
- code: 'v',
1674
- value: 'Periodicals.'
1675
- }]
1676
- }]
1677
- });
1678
- const recordValid650EngControl = new _marcRecord.MarcRecord({
1679
- leader: '',
1680
- fields: [{
1681
- tag: '650',
1682
- ind1: ' ',
1683
- ind2: '7',
1684
- subfields: [{
1685
- code: 'a',
1686
- value: 'Career Exploration.'
1687
- }, {
1688
- code: '2',
1689
- value: 'ericd'
1690
- }]
1691
- }]
1692
- });
1693
- it('Finds record valid - 647 Fast, punc char at end', async () => {
1694
- const validator = await (0, _endingPunctuation.default)();
1695
- const result = await validator.validate(recordValid647FastEndPunc);
1696
- expect(result.valid).to.eql(true);
1697
- });
1698
- it('Finds record valid - 648 Finnish, without punc', async () => {
1699
- const validator = await (0, _endingPunctuation.default)();
1700
- const result = await validator.validate(recordVali648dFinNo);
1701
- expect(result.valid).to.eql(true);
1702
- });
1703
- it('Finds record valid - 648 Fast, without punc', async () => {
1704
- const validator = await (0, _endingPunctuation.default)();
1705
- const result = await validator.validate(recordValid648FastNo);
1706
- expect(result.valid).to.eql(true);
1707
- });
1708
- it('Finds record valid - 650 Finnish, without punc', async () => {
1709
- const validator = await (0, _endingPunctuation.default)();
1710
- const result = await validator.validate(recordValid650FinNo);
1711
- expect(result.valid).to.eql(true);
1712
- });
1713
- it('Finds record valid - 650 English, punc (no control)', async () => {
1714
- const validator = await (0, _endingPunctuation.default)();
1715
- const result = await validator.validate(recordValid650EngNoControl);
1716
- expect(result.valid).to.eql(true);
1717
- });
1718
- it('Finds record valid - 650 English, with punc', async () => {
1719
- const validator = await (0, _endingPunctuation.default)();
1720
- const result = await validator.validate(recordValid650EngControl);
1721
- expect(result.valid).to.eql(true);
1722
- });
1723
-
1724
- // Invalid tests
1725
- const recordInvalid647FastEndPunc = new _marcRecord.MarcRecord({
1726
- leader: '',
1727
- fields: [{
1728
- tag: '647',
1729
- ind1: ' ',
1730
- ind2: '7',
1731
- subfields: [{
1732
- code: 'a',
1733
- value: 'Hurricane Katrina'
1734
- }, {
1735
- code: 'd',
1736
- value: '(2005).'
1737
- }, {
1738
- code: '2',
1739
- value: 'fast'
1740
- }]
1741
- }]
1742
- });
1743
- const recordInvali648dFinYes = new _marcRecord.MarcRecord({
1744
- leader: '',
1745
- fields: [{
1746
- tag: '648',
1747
- ind1: ' ',
1748
- ind2: '7',
1749
- subfields: [{
1750
- code: 'a',
1751
- value: '1900-luku.'
1752
- }, {
1753
- code: '2',
1754
- value: 'yso/swe'
1755
- }]
1756
- }]
1757
- });
1758
- const recordInvalid648FastYes = new _marcRecord.MarcRecord({
1759
- leader: '',
1760
- fields: [{
1761
- tag: '648',
1762
- ind1: ' ',
1763
- ind2: '7',
1764
- subfields: [{
1765
- code: 'a',
1766
- value: '1862.'
1767
- }, {
1768
- code: '2',
1769
- value: 'fast'
1770
- }]
1771
- }]
1772
- });
1773
- const recordInvalid650FinYes = new _marcRecord.MarcRecord({
1774
- leader: '',
1775
- fields: [{
1776
- tag: '650',
1777
- ind1: ' ',
1778
- ind2: '7',
1779
- subfields: [{
1780
- code: 'a',
1781
- value: 'kirjastot'
1782
- }, {
1783
- code: 'x',
1784
- value: 'atk-järjestelmät.'
1785
- }, {
1786
- code: '2',
1787
- value: 'kauno/fin'
1788
- }]
1789
- }, {
1790
- tag: '650',
1791
- ind1: ' ',
1792
- ind2: '7',
1793
- subfields: [{
1794
- code: 'a',
1795
- value: 'ajovalot.'
1796
- }, {
1797
- code: '2',
1798
- value: 'juho'
1799
- }]
1800
- }]
1801
- });
1802
- const recordInvalid650EngNoControl = new _marcRecord.MarcRecord({
1803
- leader: '',
1804
- fields: [{
1805
- tag: '650',
1806
- ind1: ' ',
1807
- ind2: ' ',
1808
- subfields: [{
1809
- code: 'a',
1810
- value: 'Flour industry'
1811
- }, {
1812
- code: 'v',
1813
- value: 'Periodicals'
1814
- }]
1815
- }]
1816
- });
1817
- const recordInvalid650EngControl = new _marcRecord.MarcRecord({
1818
- leader: '',
1819
- fields: [{
1820
- tag: '650',
1821
- ind1: ' ',
1822
- ind2: '7',
1823
- subfields: [{
1824
- code: 'a',
1825
- value: 'Career Exploration'
1826
- }, {
1827
- code: '2',
1828
- value: 'ericd'
1829
- }]
1830
- }]
1831
- });
1832
- it('Finds record invalid - 647 Fast, dot at end', async () => {
1833
- const validator = await (0, _endingPunctuation.default)();
1834
- const result = await validator.validate(recordInvalid647FastEndPunc);
1835
- expect(result).to.eql({
1836
- message: ['Field 647 has invalid ending punctuation'],
1837
- valid: false
1838
- });
1839
- });
1840
- it('Finds record invalid - 648 Finnish, with punc', async () => {
1841
- const validator = await (0, _endingPunctuation.default)();
1842
- const result = await validator.validate(recordInvali648dFinYes);
1843
- expect(result).to.eql({
1844
- message: ['Field 648 has invalid ending punctuation'],
1845
- valid: false
1846
- });
1847
- });
1848
- it('Finds record invalid - 648 Fast, with punc', async () => {
1849
- const validator = await (0, _endingPunctuation.default)();
1850
- const result = await validator.validate(recordInvalid648FastYes);
1851
- expect(result).to.eql({
1852
- message: ['Field 648 has invalid ending punctuation'],
1853
- valid: false
1854
- });
1855
- });
1856
- const invalidField650Message = 'Field 650 has invalid ending punctuation';
1857
- it('Finds record invalid - 650 Finnish, with punc', async () => {
1858
- const validator = await (0, _endingPunctuation.default)();
1859
- const result = await validator.validate(recordInvalid650FinYes);
1860
- expect(result).to.eql({
1861
- message: [invalidField650Message, invalidField650Message],
1862
- valid: false
1863
- });
1864
- });
1865
- it('Finds record invalid - 650 !Finnish, without punc (no control)', async () => {
1866
- const validator = await (0, _endingPunctuation.default)();
1867
- const result = await validator.validate(recordInvalid650EngNoControl);
1868
- expect(result).to.eql({
1869
- message: [invalidField650Message],
1870
- valid: false
1871
- });
1872
- });
1873
- it('Finds record invalid - 650 !Finnish, without punc', async () => {
1874
- const validator = await (0, _endingPunctuation.default)();
1875
- const result = await validator.validate(recordInvalid650EngControl);
1876
- expect(result).to.eql({
1877
- message: ['Field 650 has invalid ending punctuation'],
1878
- valid: false
1879
- });
1880
- });
1881
-
1882
- // Fix tests; invalid->valid
1883
- it('Repairs the invalid record - 647 Fast, removes double punc $d', async () => {
1884
- const validator = await (0, _endingPunctuation.default)();
1885
- const result = await validator.fix(recordInvalid647FastEndPunc);
1886
- expect(recordInvalid647FastEndPunc.equalsTo(recordValid647FastEndPunc)).to.eql(true);
1887
- expect(result).to.eql({
1888
- message: ['Field 647 has invalid ending punctuation'],
1889
- fix: ['Field 647 - Removed double punctuation from $d'],
1890
- valid: false
1891
- });
1892
- });
1893
- it('Repairs the invalid record - 648 Finnish, removes punc $a', async () => {
1894
- const validator = await (0, _endingPunctuation.default)();
1895
- const result = await validator.fix(recordInvali648dFinYes);
1896
- expect(recordInvali648dFinYes.equalsTo(recordVali648dFinNo)).to.eql(true);
1897
- expect(result).to.eql({
1898
- message: ['Field 648 has invalid ending punctuation'],
1899
- fix: ['Field 648 - Removed punctuation from $a'],
1900
- valid: false
1901
- });
1902
- });
1903
- it('Repairs the invalid record - 648 Fast, removes punc $a', async () => {
1904
- const validator = await (0, _endingPunctuation.default)();
1905
- const result = await validator.fix(recordInvalid648FastYes);
1906
- expect(recordInvalid648FastYes.equalsTo(recordValid648FastNo)).to.eql(true);
1907
- expect(result).to.eql({
1908
- message: ['Field 648 has invalid ending punctuation'],
1909
- fix: ['Field 648 - Removed punctuation from $a'],
1910
- valid: false
1911
- });
1912
- });
1913
- it('Repairs the invalid record - 650 Finnish, removes punc $x', async () => {
1914
- const validator = await (0, _endingPunctuation.default)();
1915
- const result = await validator.fix(recordInvalid650FinYes);
1916
- expect(recordInvalid650FinYes.equalsTo(recordValid650FinNo)).to.eql(true);
1917
- expect(result).to.eql({
1918
- message: [invalidField650Message, invalidField650Message],
1919
- fix: ['Field 650 - Removed punctuation from $x', 'Field 650 - Removed punctuation from $a'],
1920
- valid: false
1921
- });
1922
- });
1923
- it('Repairs the invalid record - 650 !Finnish, add punc $v (no control)', async () => {
1924
- const validator = await (0, _endingPunctuation.default)();
1925
- const result = await validator.fix(recordInvalid650EngNoControl);
1926
- expect(recordInvalid650EngNoControl.equalsTo(recordValid650EngNoControl)).to.eql(true);
1927
- expect(result).to.eql({
1928
- message: ['Field 650 has invalid ending punctuation'],
1929
- fix: ['Field 650 - Added punctuation to $v'],
1930
- valid: false
1931
- });
1932
- });
1933
- it('Repairs the invalid record - 650 !Finnish, add punc $a', async () => {
1934
- const validator = await (0, _endingPunctuation.default)();
1935
- const result = await validator.fix(recordInvalid650EngControl);
1936
- expect(recordInvalid650EngControl.equalsTo(recordValid650EngControl)).to.eql(true);
1937
- expect(result).to.eql({
1938
- message: ['Field 650 has invalid ending punctuation'],
1939
- fix: ['Field 650 - Added punctuation to $a'],
1940
- valid: false
1941
- });
1942
- });
1943
- });
1944
-
1945
- // "654-662 EI - EI suomalaisten sanastojen termeihin, muihin sanaston käytännön mukaan, yleensä KYLLÄ"
1946
- // Finnish terms at $2:['ysa', 'yso', 'kassu', 'seko', 'valo', 'kulo', 'puho', 'oiko', 'mero', 'liito', 'fast', 'allars']
1947
- // Default TRUE, until more special cases are added
1948
- describe('#654-662 TRUE - If finnish, else TRUE', () => {
1949
- // Valid tests
1950
- const recordValid655FinNo = new _marcRecord.MarcRecord({
1951
- leader: '',
1952
- fields: [{
1953
- tag: '655',
1954
- ind1: ' ',
1955
- ind2: '7',
1956
- subfields: [{
1957
- code: 'a',
1958
- value: 'kausijulkaisut'
1959
- }, {
1960
- code: '2',
1961
- value: 'yso/eng'
1962
- }]
1963
- }]
1964
- });
1965
- const recordValid655FinNo2 = new _marcRecord.MarcRecord({
1966
- leader: '',
1967
- fields: [{
1968
- tag: '655',
1969
- ind1: ' ',
1970
- ind2: '7',
1971
- subfields: [{
1972
- code: 'a',
1973
- value: 'vironkielinen kirjallisuus'
1974
- }, {
1975
- code: '2',
1976
- value: 'local'
1977
- }]
1978
- }]
1979
- });
1980
- const recordValid655EngYes = new _marcRecord.MarcRecord({
1981
- leader: '',
1982
- fields: [{
1983
- tag: '655',
1984
- ind1: ' ',
1985
- ind2: '7',
1986
- subfields: [{
1987
- code: 'a',
1988
- value: 'Bird\'s-eye views'
1989
- }, {
1990
- code: 'y',
1991
- value: '1874.'
1992
- }, {
1993
- code: '2',
1994
- value: 'gmgpc'
1995
- }]
1996
- }]
1997
- });
1998
- const recordValid655EngYesNoControl = new _marcRecord.MarcRecord({
1999
- leader: '',
2000
- fields: [{
2001
- tag: '655',
2002
- ind1: ' ',
2003
- ind2: ' ',
2004
- subfields: [{
2005
- code: 'a',
2006
- value: 'Diaries.'
2007
- }]
2008
- }]
2009
- });
2010
- const recordValid656FinNo = new _marcRecord.MarcRecord({
2011
- leader: '',
2012
- fields: [{
2013
- tag: '656',
2014
- ind1: ' ',
2015
- ind2: '7',
2016
- subfields: [{
2017
- code: 'a',
2018
- value: 'kuvaamataidonopettajat'
2019
- }, {
2020
- code: '2',
2021
- value: 'slm/eng'
2022
- }]
2023
- }]
2024
- });
2025
- const recordValid657EngYes = new _marcRecord.MarcRecord({
2026
- leader: '',
2027
- fields: [{
2028
- tag: '657',
2029
- ind1: ' ',
2030
- ind2: '7',
2031
- subfields: [{
2032
- code: 'a',
2033
- value: 'Personnel benefits management'
2034
- }, {
2035
- code: 'x',
2036
- value: 'Vital statistics'
2037
- }, {
2038
- code: 'z',
2039
- value: 'Love Canal, New York.'
2040
- }, {
2041
- code: '2',
2042
- value: 'New York State Management Functions Index'
2043
- }]
2044
- }]
2045
- });
2046
- const recordValid658EngYes = new _marcRecord.MarcRecord({
2047
- leader: '',
2048
- fields: [{
2049
- tag: '658',
2050
- ind1: ' ',
2051
- ind2: ' ',
2052
- subfields: [{
2053
- code: 'a',
2054
- value: 'Math manipulatives'
2055
- }, {
2056
- code: 'd',
2057
- value: 'highly correlated.'
2058
- }, {
2059
- code: '2',
2060
- value: '[source code]'
2061
- }]
2062
- }]
2063
- });
2064
- const recordValid662EngYes = new _marcRecord.MarcRecord({
2065
- leader: '',
2066
- fields: [{
2067
- tag: '662',
2068
- ind1: ' ',
2069
- ind2: ' ',
2070
- subfields: [{
2071
- code: 'a',
2072
- value: 'Antarctica.'
2073
- }, {
2074
- code: '2',
2075
- value: 'lcsh/naf'
2076
- }]
2077
- }]
2078
- });
2079
- it('Finds record valid - 655 Finnish, no punc $a', async () => {
2080
- const validator = await (0, _endingPunctuation.default)();
2081
- const result = await validator.validate(recordValid655FinNo);
2082
- expect(result.valid).to.eql(true);
2083
- });
2084
- it('Finds record valid - 655 Finnish, without punc', async () => {
2085
- const validator = await (0, _endingPunctuation.default)();
2086
- const result = await validator.validate(recordValid655FinNo2);
2087
- expect(result.valid).to.eql(true);
2088
- });
2089
- it('Finds record valid - 655 English, with punc $y', async () => {
2090
- const validator = await (0, _endingPunctuation.default)();
2091
- const result = await validator.validate(recordValid655EngYes);
2092
- expect(result.valid).to.eql(true);
2093
- });
2094
- it('Finds record valid - 655 English, with punc $a (no control)', async () => {
2095
- const validator = await (0, _endingPunctuation.default)();
2096
- const result = await validator.validate(recordValid655EngYesNoControl);
2097
- expect(result.valid).to.eql(true);
2098
- });
2099
- it('Finds record valid - 656 Finnish, without punc $a', async () => {
2100
- const validator = await (0, _endingPunctuation.default)();
2101
- const result = await validator.validate(recordValid656FinNo);
2102
- expect(result.valid).to.eql(true);
2103
- });
2104
- it('Finds record valid - 657 English, with punc $z', async () => {
2105
- const validator = await (0, _endingPunctuation.default)();
2106
- const result = await validator.validate(recordValid657EngYes);
2107
- expect(result.valid).to.eql(true);
2108
- });
2109
- it('Finds record valid - 658 English, with punc $d', async () => {
2110
- const validator = await (0, _endingPunctuation.default)();
2111
- const result = await validator.validate(recordValid658EngYes);
2112
- expect(result.valid).to.eql(true);
2113
- });
2114
- it('Finds record valid - 662 English, with punc $a', async () => {
2115
- const validator = await (0, _endingPunctuation.default)();
2116
- const result = await validator.validate(recordValid662EngYes);
2117
- expect(result.valid).to.eql(true);
2118
- });
2119
-
2120
- // Invalid tests
2121
- const recordInvalid655FinYes = new _marcRecord.MarcRecord({
2122
- leader: '',
2123
- fields: [{
2124
- tag: '655',
2125
- ind1: ' ',
2126
- ind2: '7',
2127
- subfields: [{
2128
- code: 'a',
2129
- value: 'kausijulkaisut.'
2130
- }, {
2131
- code: '2',
2132
- value: 'yso/eng'
2133
- }]
2134
- }]
2135
- });
2136
- const recordInvalid655FinYes2 = new _marcRecord.MarcRecord({
2137
- leader: '',
2138
- fields: [{
2139
- tag: '655',
2140
- ind1: ' ',
2141
- ind2: '7',
2142
- subfields: [{
2143
- code: 'a',
2144
- value: 'vironkielinen kirjallisuus.'
2145
- }, {
2146
- code: '2',
2147
- value: 'local'
2148
- }]
2149
- }]
2150
- });
2151
- const recordInvalid655EngNo = new _marcRecord.MarcRecord({
2152
- leader: '',
2153
- fields: [{
2154
- tag: '655',
2155
- ind1: ' ',
2156
- ind2: '7',
2157
- subfields: [{
2158
- code: 'a',
2159
- value: 'Bird\'s-eye views'
2160
- }, {
2161
- code: 'y',
2162
- value: '1874'
2163
- }, {
2164
- code: '2',
2165
- value: 'gmgpc'
2166
- }]
2167
- }]
2168
- });
2169
- const recordInvalid655EngNoNoControl = new _marcRecord.MarcRecord({
2170
- leader: '',
2171
- fields: [{
2172
- tag: '655',
2173
- ind1: ' ',
2174
- ind2: ' ',
2175
- subfields: [{
2176
- code: 'a',
2177
- value: 'Diaries'
2178
- }]
2179
- }]
2180
- });
2181
- const recordInvalid656FinYes = new _marcRecord.MarcRecord({
2182
- leader: '',
2183
- fields: [{
2184
- tag: '656',
2185
- ind1: ' ',
2186
- ind2: '7',
2187
- subfields: [{
2188
- code: 'a',
2189
- value: 'kuvaamataidonopettajat.'
2190
- }, {
2191
- code: '2',
2192
- value: 'slm/eng'
2193
- }]
2194
- }]
2195
- });
2196
- const recordInvalid657EngNo = new _marcRecord.MarcRecord({
2197
- leader: '',
2198
- fields: [{
2199
- tag: '657',
2200
- ind1: ' ',
2201
- ind2: '7',
2202
- subfields: [{
2203
- code: 'a',
2204
- value: 'Personnel benefits management'
2205
- }, {
2206
- code: 'x',
2207
- value: 'Vital statistics'
2208
- }, {
2209
- code: 'z',
2210
- value: 'Love Canal, New York'
2211
- }, {
2212
- code: '2',
2213
- value: 'New York State Management Functions Index'
2214
- }]
2215
- }]
2216
- });
2217
- const recordInvalid658EngNo = new _marcRecord.MarcRecord({
2218
- leader: '',
2219
- fields: [{
2220
- tag: '658',
2221
- ind1: ' ',
2222
- ind2: ' ',
2223
- subfields: [{
2224
- code: 'a',
2225
- value: 'Math manipulatives'
2226
- }, {
2227
- code: 'd',
2228
- value: 'highly correlated'
2229
- }, {
2230
- code: '2',
2231
- value: '[source code]'
2232
- }]
2233
- }]
2234
- });
2235
- const recordInvalid662EngNo = new _marcRecord.MarcRecord({
2236
- leader: '',
2237
- fields: [{
2238
- tag: '662',
2239
- ind1: ' ',
2240
- ind2: ' ',
2241
- subfields: [{
2242
- code: 'a',
2243
- value: 'Antarctica'
2244
- }, {
2245
- code: '2',
2246
- value: 'lcsh/naf'
2247
- }]
2248
- }]
2249
- });
2250
- it('Finds record invalid - 655 Finnish, punc $a', async () => {
2251
- const validator = await (0, _endingPunctuation.default)();
2252
- const result = await validator.validate(recordInvalid655FinYes);
2253
- expect(result).to.eql({
2254
- message: ['Field 655 has invalid ending punctuation'],
2255
- valid: false
2256
- });
2257
- });
2258
- it('Finds record invalid - 655 Finnish, with punc', async () => {
2259
- const validator = await (0, _endingPunctuation.default)();
2260
- const result = await validator.validate(recordInvalid655FinYes2);
2261
- expect(result).to.eql({
2262
- message: ['Field 655 has invalid ending punctuation'],
2263
- valid: false
2264
- });
2265
- });
2266
- it('Finds record invalid - 655 !Finnish, without punc $y', async () => {
2267
- const validator = await (0, _endingPunctuation.default)();
2268
- const result = await validator.validate(recordInvalid655EngNo);
2269
- expect(result).to.eql({
2270
- message: ['Field 655 has invalid ending punctuation'],
2271
- valid: false
2272
- });
2273
- });
2274
- it('Finds record invalid - 655 !Finnish, without punc $a (no control)', async () => {
2275
- const validator = await (0, _endingPunctuation.default)();
2276
- const result = await validator.validate(recordInvalid655EngNoNoControl);
2277
- expect(result).to.eql({
2278
- message: ['Field 655 has invalid ending punctuation'],
2279
- valid: false
2280
- });
2281
- });
2282
- it('Finds record invalid - 656 Finnish, with punc $a', async () => {
2283
- const validator = await (0, _endingPunctuation.default)();
2284
- const result = await validator.validate(recordInvalid656FinYes);
2285
- expect(result).to.eql({
2286
- message: ['Field 656 has invalid ending punctuation'],
2287
- valid: false
2288
- });
2289
- });
2290
- it('Finds record invalid - 657 !Finnish, without punc $z', async () => {
2291
- const validator = await (0, _endingPunctuation.default)();
2292
- const result = await validator.validate(recordInvalid657EngNo);
2293
- expect(result).to.eql({
2294
- message: ['Field 657 has invalid ending punctuation'],
2295
- valid: false
2296
- });
2297
- });
2298
- it('Finds record invalid - 658 !Finnish, without punc $d', async () => {
2299
- const validator = await (0, _endingPunctuation.default)();
2300
- const result = await validator.validate(recordInvalid658EngNo);
2301
- expect(result).to.eql({
2302
- message: ['Field 658 has invalid ending punctuation'],
2303
- valid: false
2304
- });
2305
- });
2306
- it('Finds record invalid - 662 !Finnish, without punc $a', async () => {
2307
- const validator = await (0, _endingPunctuation.default)();
2308
- const result = await validator.validate(recordInvalid662EngNo);
2309
- expect(result).to.eql({
2310
- message: ['Field 662 has invalid ending punctuation'],
2311
- valid: false
2312
- });
2313
- });
2314
-
2315
- // Fix tests; invalid->valid
2316
- it('Repairs the invalid record - 655 Finnish, remove punc $a', async () => {
2317
- const validator = await (0, _endingPunctuation.default)();
2318
- const result = await validator.fix(recordInvalid655FinYes);
2319
- expect(recordInvalid655FinYes.equalsTo(recordValid655FinNo)).to.eql(true);
2320
- expect(result).to.eql({
2321
- message: ['Field 655 has invalid ending punctuation'],
2322
- fix: ['Field 655 - Removed punctuation from $a'],
2323
- valid: false
2324
- });
2325
- });
2326
- it('Repairs the invalid record - 655 Finnish, removes punc $a 2', async () => {
2327
- const validator = await (0, _endingPunctuation.default)();
2328
- const result = await validator.fix(recordInvalid655FinYes2);
2329
- expect(recordInvalid655FinYes2.equalsTo(recordValid655FinNo2)).to.eql(true);
2330
- expect(result).to.eql({
2331
- message: ['Field 655 has invalid ending punctuation'],
2332
- fix: ['Field 655 - Removed punctuation from $a'],
2333
- valid: false
2334
- });
2335
- });
2336
- it('Repairs the invalid record - 655 !Finnish, add punc $y', async () => {
2337
- const validator = await (0, _endingPunctuation.default)();
2338
- const result = await validator.fix(recordInvalid655EngNo);
2339
- expect(recordInvalid655EngNo.equalsTo(recordValid655EngYes)).to.eql(true);
2340
- expect(result).to.eql({
2341
- message: ['Field 655 has invalid ending punctuation'],
2342
- fix: ['Field 655 - Added punctuation to $y'],
2343
- valid: false
2344
- });
2345
- });
2346
- it('Repairs the invalid record - 655 !Finnish, add punc $a (no control)', async () => {
2347
- const validator = await (0, _endingPunctuation.default)();
2348
- const result = await validator.fix(recordInvalid655EngNoNoControl);
2349
- expect(recordInvalid655EngNoNoControl.equalsTo(recordValid655EngYesNoControl)).to.eql(true);
2350
- expect(result).to.eql({
2351
- message: ['Field 655 has invalid ending punctuation'],
2352
- fix: ['Field 655 - Added punctuation to $a'],
2353
- valid: false
2354
- });
2355
- });
2356
- it('Repairs the invalid record - 656 Finnish, remove punc $a', async () => {
2357
- const validator = await (0, _endingPunctuation.default)();
2358
- const result = await validator.fix(recordInvalid656FinYes);
2359
- expect(recordInvalid656FinYes.equalsTo(recordValid656FinNo)).to.eql(true);
2360
- expect(result).to.eql({
2361
- message: ['Field 656 has invalid ending punctuation'],
2362
- fix: ['Field 656 - Removed punctuation from $a'],
2363
- valid: false
2364
- });
2365
- });
2366
- it('Repairs the invalid record - 657 !Finnish, add punc $z', async () => {
2367
- const validator = await (0, _endingPunctuation.default)();
2368
- const result = await validator.fix(recordInvalid657EngNo);
2369
- expect(recordInvalid657EngNo.equalsTo(recordValid657EngYes)).to.eql(true);
2370
- expect(result).to.eql({
2371
- message: ['Field 657 has invalid ending punctuation'],
2372
- fix: ['Field 657 - Added punctuation to $z'],
2373
- valid: false
2374
- });
2375
- });
2376
- it('Repairs the invalid record - 658 !Finnish, add punc $d', async () => {
2377
- const validator = await (0, _endingPunctuation.default)();
2378
- const result = await validator.fix(recordInvalid658EngNo);
2379
- expect(recordInvalid658EngNo.equalsTo(recordValid658EngYes)).to.eql(true);
2380
- expect(result).to.eql({
2381
- message: ['Field 658 has invalid ending punctuation'],
2382
- fix: ['Field 658 - Added punctuation to $d'],
2383
- valid: false
2384
- });
2385
- });
2386
- it('Repairs the invalid record - 662 !Finnish, add pun $a', async () => {
2387
- const validator = await (0, _endingPunctuation.default)();
2388
- const result = await validator.fix(recordInvalid662EngNo);
2389
- expect(recordInvalid662EngNo.equalsTo(recordValid662EngYes)).to.eql(true);
2390
- expect(result).to.eql({
2391
- message: ['Field 662 has invalid ending punctuation'],
2392
- fix: ['Field 662 - Added punctuation to $a'],
2393
- valid: false
2394
- });
2395
- });
2396
- });
2397
-
2398
- // "760-787 KYLLÄ osakentän $a jälkeen, EI muiden osakenttien jälkeen" (kuten 567)
2399
- // Only if last subfield $a
2400
- describe('#760-787 TRUE - After subfield $a, FALSE after others', () => {
2401
- // Valid tests
2402
- const recordValid = new _marcRecord.MarcRecord({
2403
- leader: '',
2404
- fields: [{
2405
- tag: '760',
2406
- ind1: ' ',
2407
- ind2: ' ',
2408
- subfields: [{
2409
- code: 'a',
2410
- value: 'Mellor, Alec.'
2411
- }, {
2412
- code: 't',
2413
- value: 'Strange masonic stories'
2414
- }, {
2415
- code: 'e',
2416
- value: 'eng'
2417
- }]
2418
- }]
2419
- });
2420
- const recordValidOnlyA = new _marcRecord.MarcRecord({
2421
- leader: '',
2422
- fields: [{
2423
- tag: '760',
2424
- ind1: ' ',
2425
- ind2: ' ',
2426
- subfields: [{
2427
- code: 'a',
2428
- value: 'Mellor, Alec.'
2429
- }]
2430
- }]
2431
- });
2432
- it('Finds record valid - Punc $a, but following fields, $e no punc (last)', async () => {
2433
- const validator = await (0, _endingPunctuation.default)();
2434
- const result = await validator.validate(recordValid);
2435
- expect(result.valid).to.eql(true);
2436
- });
2437
- it('Finds record valid - Punc $a (only)', async () => {
2438
- const validator = await (0, _endingPunctuation.default)();
2439
- const result = await validator.validate(recordValidOnlyA);
2440
- expect(result.valid).to.eql(true);
2441
- });
2442
-
2443
- // Invalid tests
2444
- const recordInvalid = new _marcRecord.MarcRecord({
2445
- leader: '',
2446
- fields: [{
2447
- tag: '760',
2448
- ind1: ' ',
2449
- ind2: ' ',
2450
- subfields: [{
2451
- code: 'a',
2452
- value: 'Mellor, Alec.'
2453
- }, {
2454
- code: 't',
2455
- value: 'Strange masonic stories'
2456
- }, {
2457
- code: 'e',
2458
- value: 'eng.'
2459
- }]
2460
- }]
2461
- });
2462
- const recordInvalidOnlyA = new _marcRecord.MarcRecord({
2463
- leader: '',
2464
- fields: [{
2465
- tag: '760',
2466
- ind1: ' ',
2467
- ind2: ' ',
2468
- subfields: [{
2469
- code: 'a',
2470
- value: 'Mellor, Alec'
2471
- }]
2472
- }]
2473
- });
2474
- it('Finds record invalid - Punc $e (language field, strict)', async () => {
2475
- const validator = await (0, _endingPunctuation.default)();
2476
- const result = await validator.validate(recordInvalid);
2477
- expect(result).to.eql({
2478
- message: ['Field 760 has invalid ending punctuation'],
2479
- valid: false
2480
- });
2481
- });
2482
- it('Finds record invalid - No punc $a (only)', async () => {
2483
- const validator = await (0, _endingPunctuation.default)();
2484
- const result = await validator.validate(recordInvalidOnlyA);
2485
- expect(result).to.eql({
2486
- message: ['Field 760 has invalid ending punctuation'],
2487
- valid: false
2488
- });
2489
- });
2490
-
2491
- // Fix tests; invalid->valid
2492
- it('Repairs the invalid record - Remove punc $e (language field, strict)', async () => {
2493
- const validator = await (0, _endingPunctuation.default)();
2494
- const result = await validator.fix(recordInvalid);
2495
- expect(recordInvalid.equalsTo(recordValid)).to.eql(true);
2496
- expect(result).to.eql({
2497
- message: ['Field 760 has invalid ending punctuation'],
2498
- fix: ['Field 760 - Removed punctuation from $e'],
2499
- valid: false
2500
- });
2501
- });
2502
- it('Repairs the invalid record - Add punc $a (only)', async () => {
2503
- const validator = await (0, _endingPunctuation.default)();
2504
- const result = await validator.fix(recordInvalidOnlyA);
2505
- expect(recordInvalidOnlyA.equalsTo(recordValidOnlyA)).to.eql(true);
2506
- expect(result).to.eql({
2507
- message: ['Field 760 has invalid ending punctuation'],
2508
- fix: ['Field 760 - Added punctuation to $a'],
2509
- valid: false
2510
- });
2511
- });
2512
- });
2513
-
2514
- // "`880`-kenttä: https://www.kansalliskirjasto.fi/extra/marc21/bib/841-88X.htm#880 Eli tää on se Loppupisteohjeen `Samoin kuin vastaavat kentät` -keissi
2515
- // Spex on siinä, mutta lyhkäsesti: `880`-kentässä on muiden kenttien translitteroidut versiot (Data eri kirjaimistolla). 880-kentän osakentästä `6` selviää mihin kenttää se linkkaa."
2516
- // 880 Samoin kuin vastaavat kentät - Siis tarkistetaan kontrollikentän $6 säännön
2517
- describe('#880 - Like linked fields', () => {
2518
- // Valid tests
2519
- const recordValidSimple = new _marcRecord.MarcRecord({
2520
- leader: '',
2521
- fields: [{
2522
- tag: '880',
2523
- ind1: ' ',
2524
- ind2: ' ',
2525
- subfields: [{
2526
- code: 'a',
2527
- value: '平田 篤胤'
2528
- }, {
2529
- code: 'b',
2530
- value: '1776-1843.'
2531
- }, {
2532
- code: '6',
2533
- value: '100-01/$1'
2534
- } // Tag 100 has value TRUE -> last data subfield should have punc
2535
- ]
2536
- }]
2537
- });
2538
- const recordValidComplex = new _marcRecord.MarcRecord({
2539
- leader: '',
2540
- fields: [{
2541
- tag: '880',
2542
- ind1: ' ',
2543
- ind2: ' ',
2544
- subfields: [{
2545
- code: 'b',
2546
- value: 'ידיעות אחרונות'
2547
- }, {
2548
- code: 'b',
2549
- value: 'ספרי חמד'
2550
- }, {
2551
- code: 'c',
2552
- value: '2006.'
2553
- }, {
2554
- code: '6',
2555
- value: '260-02/(2/r ‡a תל-אביב'
2556
- } // Tag 260 has value TRUE -> last data subfield should have punc
2557
- ]
2558
- }]
2559
- });
2560
- it('Finds record valid - Punc $b', async () => {
2561
- const validator = await (0, _endingPunctuation.default)();
2562
- const result = await validator.validate(recordValidSimple);
2563
- expect(result.valid).to.eql(true);
2564
- });
2565
- it('Finds record valid - Punc $c', async () => {
2566
- const validator = await (0, _endingPunctuation.default)();
2567
- const result = await validator.validate(recordValidComplex);
2568
- expect(result.valid).to.eql(true);
2569
- });
2570
-
2571
- // Invalid tests
2572
- const recordInvalidSimple = new _marcRecord.MarcRecord({
2573
- leader: '',
2574
- fields: [{
2575
- tag: '880',
2576
- ind1: ' ',
2577
- ind2: ' ',
2578
- subfields: [{
2579
- code: 'a',
2580
- value: '平田 篤胤'
2581
- }, {
2582
- code: 'b',
2583
- value: '1776-1843'
2584
- }, {
2585
- code: '6',
2586
- value: '100-01/$1'
2587
- } // Tag 100 has value TRUE -> last data subfield should have punc
2588
- ]
2589
- }]
2590
- });
2591
- const recordInvalidComplex = new _marcRecord.MarcRecord({
2592
- leader: '',
2593
- fields: [{
2594
- tag: '880',
2595
- ind1: ' ',
2596
- ind2: ' ',
2597
- subfields: [{
2598
- code: 'b',
2599
- value: 'ידיעות אחרונות'
2600
- }, {
2601
- code: 'b',
2602
- value: 'ספרי חמד'
2603
- }, {
2604
- code: 'c',
2605
- value: '2006'
2606
- }, {
2607
- code: '6',
2608
- value: '260-02/(2/r ‡a תל-אביב'
2609
- } // Tag 260 has value TRUE -> last data subfield should have punc
2610
- ]
2611
- }]
2612
- });
2613
- it('Finds record invalid - No punc $b', async () => {
2614
- const validator = await (0, _endingPunctuation.default)();
2615
- const result = await validator.validate(recordInvalidSimple);
2616
- expect(result).to.eql({
2617
- message: ['Field 880 has invalid ending punctuation'],
2618
- valid: false
2619
- });
2620
- });
2621
- it('Finds record invalid - No punc $c', async () => {
2622
- const validator = await (0, _endingPunctuation.default)();
2623
- const result = await validator.validate(recordInvalidComplex);
2624
- expect(result).to.eql({
2625
- message: ['Field 880 has invalid ending punctuation'],
2626
- valid: false
2627
- });
2628
- });
2629
-
2630
- // Fix tests; invalid->valid
2631
- it('Repairs the invalid record - Add punc $b', async () => {
2632
- const validator = await (0, _endingPunctuation.default)();
2633
- const result = await validator.fix(recordInvalidSimple);
2634
- expect(recordInvalidSimple.equalsTo(recordValidSimple)).to.eql(true);
2635
- expect(result).to.eql({
2636
- message: ['Field 880 has invalid ending punctuation'],
2637
- fix: ['Field 880 - Added punctuation to $b'],
2638
- valid: false
2639
- });
2640
- });
2641
- it('Repairs the invalid record - Add punc $c', async () => {
2642
- const validator = await (0, _endingPunctuation.default)();
2643
- const result = await validator.fix(recordInvalidComplex);
2644
- expect(recordInvalidComplex.equalsTo(recordValidComplex)).to.eql(true);
2645
- expect(result).to.eql({
2646
- message: ['Field 880 has invalid ending punctuation'],
2647
- fix: ['Field 880 - Added punctuation to $c'],
2648
- valid: false
2649
- });
2650
- });
2651
- });
2652
- });
2653
- });
2654
- //# sourceMappingURL=ending-punctuation.spec.js.map