@natlibfi/marc-record-validators-melinda 3.2.0 → 3.3.14-alpha.3

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