@natlibfi/marc-record-merge 5.0.0 → 6.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.drone.yml +92 -0
- package/.github/CODEOWNERS +9 -0
- package/.github/dependabot.yml +41 -0
- package/.github/workflows/melinda-node-tests.yml +60 -0
- package/LICENSE +21 -0
- package/README.md +64 -246
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/reducers/copy.js +297 -0
- package/dist/reducers/copy.js.map +1 -0
- package/dist/reducers/copy.spec.js +68 -0
- package/dist/reducers/copy.spec.js.map +1 -0
- package/dist/reducers/index.js +25 -0
- package/dist/reducers/index.js.map +1 -0
- package/dist/reducers/select.js +130 -0
- package/dist/reducers/select.js.map +1 -0
- package/dist/reducers/select.spec.js +68 -0
- package/dist/reducers/select.spec.js.map +1 -0
- package/package.json +103 -57
- package/src/index.js +4 -0
- package/src/reducers/copy.js +274 -0
- package/src/reducers/copy.spec.js +48 -0
- package/src/reducers/index.js +4 -0
- package/src/reducers/select.js +107 -0
- package/src/reducers/select.spec.js +45 -0
- package/test-fixtures/reducers/copy/basic copy/01/base.json +9 -0
- package/test-fixtures/reducers/copy/basic copy/01/merged.json +20 -0
- package/test-fixtures/reducers/copy/basic copy/01/metadata.json +5 -0
- package/test-fixtures/reducers/copy/basic copy/01/source.json +20 -0
- package/test-fixtures/reducers/copy/basic copy/02/base.json +20 -0
- package/test-fixtures/reducers/copy/basic copy/02/merged.json +20 -0
- package/test-fixtures/reducers/copy/basic copy/02/metadata.json +5 -0
- package/test-fixtures/reducers/copy/basic copy/02/source.json +20 -0
- package/test-fixtures/reducers/copy/basic copy/03/base.json +20 -0
- package/test-fixtures/reducers/copy/basic copy/03/merged.json +28 -0
- package/test-fixtures/reducers/copy/basic copy/03/metadata.json +5 -0
- package/test-fixtures/reducers/copy/basic copy/03/source.json +24 -0
- package/test-fixtures/reducers/copy/basic copy/04/base.json +39 -0
- package/test-fixtures/reducers/copy/basic copy/04/merged.json +39 -0
- package/test-fixtures/reducers/copy/basic copy/04/metadata.json +5 -0
- package/test-fixtures/reducers/copy/basic copy/04/source.json +39 -0
- package/test-fixtures/reducers/copy/basic copy/05/base.json +39 -0
- package/test-fixtures/reducers/copy/basic copy/05/merged.json +77 -0
- package/test-fixtures/reducers/copy/basic copy/05/metadata.json +5 -0
- package/test-fixtures/reducers/copy/basic copy/05/source.json +62 -0
- package/test-fixtures/reducers/copy/basic copy/06/base.json +24 -0
- package/test-fixtures/reducers/copy/basic copy/06/merged.json +39 -0
- package/test-fixtures/reducers/copy/basic copy/06/metadata.json +5 -0
- package/test-fixtures/reducers/copy/basic copy/06/source.json +24 -0
- package/test-fixtures/reducers/copy/compareTagsOnly/01/base.json +24 -0
- package/test-fixtures/reducers/copy/compareTagsOnly/01/merged.json +24 -0
- package/test-fixtures/reducers/copy/compareTagsOnly/01/metadata.json +6 -0
- package/test-fixtures/reducers/copy/compareTagsOnly/01/source.json +24 -0
- package/test-fixtures/reducers/copy/compareTagsOnly/02/base.json +24 -0
- package/test-fixtures/reducers/copy/compareTagsOnly/02/merged.json +100 -0
- package/test-fixtures/reducers/copy/compareTagsOnly/02/metadata.json +6 -0
- package/test-fixtures/reducers/copy/compareTagsOnly/02/source.json +100 -0
- package/test-fixtures/reducers/copy/compareWithoutIndicators/01/base.json +24 -0
- package/test-fixtures/reducers/copy/compareWithoutIndicators/01/merged.json +24 -0
- package/test-fixtures/reducers/copy/compareWithoutIndicators/01/metadata.json +6 -0
- package/test-fixtures/reducers/copy/compareWithoutIndicators/01/source.json +24 -0
- package/test-fixtures/reducers/copy/compareWithoutIndicators/02/base.json +24 -0
- package/test-fixtures/reducers/copy/compareWithoutIndicators/02/merged.json +39 -0
- package/test-fixtures/reducers/copy/compareWithoutIndicators/02/metadata.json +6 -0
- package/test-fixtures/reducers/copy/compareWithoutIndicators/02/source.json +24 -0
- package/test-fixtures/reducers/copy/copyUnless/01/base.json +9 -0
- package/test-fixtures/reducers/copy/copyUnless/01/merged.json +24 -0
- package/test-fixtures/reducers/copy/copyUnless/01/metadata.json +6 -0
- package/test-fixtures/reducers/copy/copyUnless/01/source.json +47 -0
- package/test-fixtures/reducers/copy/dropSubfields/01/base.json +35 -0
- package/test-fixtures/reducers/copy/dropSubfields/01/merged.json +54 -0
- package/test-fixtures/reducers/copy/dropSubfields/01/metadata.json +6 -0
- package/test-fixtures/reducers/copy/dropSubfields/01/source.json +43 -0
- package/test-fixtures/reducers/copy/dropSubfields/02/base.json +43 -0
- package/test-fixtures/reducers/copy/dropSubfields/02/merged.json +58 -0
- package/test-fixtures/reducers/copy/dropSubfields/02/metadata.json +6 -0
- package/test-fixtures/reducers/copy/dropSubfields/02/source.json +32 -0
- package/test-fixtures/reducers/copy/dropSubfields/03/base.json +43 -0
- package/test-fixtures/reducers/copy/dropSubfields/03/merged.json +58 -0
- package/test-fixtures/reducers/copy/dropSubfields/03/metadata.json +6 -0
- package/test-fixtures/reducers/copy/dropSubfields/03/source.json +32 -0
- package/test-fixtures/reducers/copy/dropSubfields/04/base.json +43 -0
- package/test-fixtures/reducers/copy/dropSubfields/04/merged.json +43 -0
- package/test-fixtures/reducers/copy/dropSubfields/04/metadata.json +6 -0
- package/test-fixtures/reducers/copy/dropSubfields/04/source.json +32 -0
- package/test-fixtures/reducers/copy/excludeSubfields/01/base.json +39 -0
- package/test-fixtures/reducers/copy/excludeSubfields/01/merged.json +39 -0
- package/test-fixtures/reducers/copy/excludeSubfields/01/metadata.json +9 -0
- package/test-fixtures/reducers/copy/excludeSubfields/01/source.json +43 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/01/base.json +24 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/01/merged.json +39 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/01/metadata.json +6 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/01/source.json +24 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/02/base.json +24 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/02/merged.json +24 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/02/metadata.json +6 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/02/source.json +24 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/03/base.json +28 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/03/merged.json +43 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/03/metadata.json +6 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/03/source.json +24 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/04/base.json +28 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/04/merged.json +28 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/04/metadata.json +6 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/04/source.json +24 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/05/base.json +20 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/05/merged.json +35 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/05/metadata.json +6 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/05/source.json +24 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/06/base.json +20 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/06/merged.json +35 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/06/metadata.json +6 -0
- package/test-fixtures/reducers/copy/subfieldsMustBeIdentical/06/source.json +24 -0
- package/test-fixtures/reducers/metadata.json +5 -0
- package/test-fixtures/reducers/select/01/base.json +21 -0
- package/test-fixtures/reducers/select/01/merged.json +20 -0
- package/test-fixtures/reducers/select/01/metadata.json +5 -0
- package/test-fixtures/reducers/select/01/source.json +20 -0
- package/test-fixtures/reducers/select/02/base.json +31 -0
- package/test-fixtures/reducers/select/02/merged.json +31 -0
- package/test-fixtures/reducers/select/02/metadata.json +4 -0
- package/test-fixtures/reducers/select/02/source.json +42 -0
- package/test-fixtures/reducers/select/03/base.json +20 -0
- package/test-fixtures/reducers/select/03/merged.json +20 -0
- package/test-fixtures/reducers/select/03/metadata.json +4 -0
- package/test-fixtures/reducers/select/03/source.json +20 -0
- package/test-fixtures/reducers/select/04/base.json +20 -0
- package/test-fixtures/reducers/select/04/merged.json +20 -0
- package/test-fixtures/reducers/select/04/metadata.json +5 -0
- package/test-fixtures/reducers/select/04/source.json +20 -0
- package/test-fixtures/reducers/select/05/base.json +24 -0
- package/test-fixtures/reducers/select/05/merged.json +24 -0
- package/test-fixtures/reducers/select/05/metadata.json +4 -0
- package/test-fixtures/reducers/select/05/source.json +24 -0
- package/test-fixtures/reducers/select/06/base.json +28 -0
- package/test-fixtures/reducers/select/06/merged.json +28 -0
- package/test-fixtures/reducers/select/06/metadata.json +4 -0
- package/test-fixtures/reducers/select/06/source.json +28 -0
- package/test-fixtures/reducers/select/07/base.json +24 -0
- package/test-fixtures/reducers/select/07/merged.json +24 -0
- package/test-fixtures/reducers/select/07/metadata.json +5 -0
- package/test-fixtures/reducers/select/07/source.json +24 -0
- package/test-fixtures/reducers/select/08/base.json +24 -0
- package/test-fixtures/reducers/select/08/merged.json +24 -0
- package/test-fixtures/reducers/select/08/metadata.json +4 -0
- package/test-fixtures/reducers/select/08/source.json +24 -0
- package/test-fixtures/reducers/select/09/base.json +24 -0
- package/test-fixtures/reducers/select/09/merged.json +24 -0
- package/test-fixtures/reducers/select/09/metadata.json +4 -0
- package/test-fixtures/reducers/select/09/source.json +24 -0
- package/test-fixtures/reducers/select/10/base.json +24 -0
- package/test-fixtures/reducers/select/10/merged.json +28 -0
- package/test-fixtures/reducers/select/10/metadata.json +5 -0
- package/test-fixtures/reducers/select/10/source.json +28 -0
- package/test-fixtures/reducers/select/11/base.json +24 -0
- package/test-fixtures/reducers/select/11/merged.json +24 -0
- package/test-fixtures/reducers/select/11/metadata.json +4 -0
- package/test-fixtures/reducers/select/11/source.json +28 -0
- package/test-fixtures/reducers/select/12/base.json +24 -0
- package/test-fixtures/reducers/select/12/merged.json +28 -0
- package/test-fixtures/reducers/select/12/metadata.json +5 -0
- package/test-fixtures/reducers/select/12/source.json +28 -0
- package/test-fixtures/reducers/select/13/base.json +28 -0
- package/test-fixtures/reducers/select/13/merged.json +28 -0
- package/test-fixtures/reducers/select/13/metadata.json +4 -0
- package/test-fixtures/reducers/select/13/source.json +24 -0
- package/test-fixtures/reducers/select/14/base.json +24 -0
- package/test-fixtures/reducers/select/14/merged.json +24 -0
- package/test-fixtures/reducers/select/14/metadata.json +4 -0
- package/test-fixtures/reducers/select/14/source.json +24 -0
- package/.editorconfig +0 -10
- package/.istanbul.yml +0 -6
- package/.jshintignore +0 -2
- package/.jshintrc +0 -3
- package/.travis.yml +0 -16
- package/LICENSE.txt +0 -661
- package/karma.conf.js +0 -39
- package/lib/main.js +0 -1215
- package/resources/action-copy-options-schema.json +0 -81
- package/resources/action-select-better-options-schema.json +0 -34
- package/resources/configuration-schema.json +0 -46
- package/test/browser/main.spec.js +0 -96
- package/test/nodejs/main.spec.js +0 -71
- package/test/suites/74.json +0 -10
- package/test/suites/config/1to3.json +0 -10
- package/test/suites/config/27to28.json +0 -10
- package/test/suites/config/29to31.json +0 -10
- package/test/suites/config/32to40.json +0 -16
- package/test/suites/config/41to43.json +0 -10
- package/test/suites/config/44to56.json +0 -15
- package/test/suites/config/4to26.json +0 -81
- package/test/suites/config/57to63.json +0 -63
- package/test/suites/config/64.json +0 -7
- package/test/suites/config/65.json +0 -19
- package/test/suites/config/66.json +0 -13
- package/test/suites/config/67.json +0 -14
- package/test/suites/config/68.json +0 -12
- package/test/suites/config/69.json +0 -12
- package/test/suites/config/70.json +0 -13
- package/test/suites/config/71.json +0 -10
- package/test/suites/config/72.json +0 -12
- package/test/suites/config/73.json +0 -10
- package/test/suites/config/76.json +0 -13
- package/test/suites/config/77.json +0 -11
- package/test/suites/config/78to79.json +0 -12
- package/test/suites/config/80to81.json +0 -12
- package/test/suites/config/82.json +0 -10
- package/test/suites/config/83to85.json +0 -15
- package/test/suites/config/86.json +0 -16
- package/test/suites/config/87.json +0 -15
- package/test/suites/config/88.json +0 -16
- package/test/suites/data/1/merged +0 -3
- package/test/suites/data/1/other +0 -3
- package/test/suites/data/1/preferred +0 -2
- package/test/suites/data/10/descr +0 -1
- package/test/suites/data/10/merged +0 -2
- package/test/suites/data/10/other +0 -2
- package/test/suites/data/10/preferred +0 -2
- package/test/suites/data/11/descr +0 -1
- package/test/suites/data/11/merged +0 -2
- package/test/suites/data/11/other +0 -2
- package/test/suites/data/11/preferred +0 -2
- package/test/suites/data/12/descr +0 -1
- package/test/suites/data/12/merged +0 -2
- package/test/suites/data/12/other +0 -2
- package/test/suites/data/12/preferred +0 -2
- package/test/suites/data/13/descr +0 -1
- package/test/suites/data/13/merged +0 -3
- package/test/suites/data/13/other +0 -2
- package/test/suites/data/13/preferred +0 -3
- package/test/suites/data/14/descr +0 -1
- package/test/suites/data/14/merged +0 -2
- package/test/suites/data/14/other +0 -2
- package/test/suites/data/14/preferred +0 -2
- package/test/suites/data/15/descr +0 -1
- package/test/suites/data/15/merged +0 -2
- package/test/suites/data/15/other +0 -2
- package/test/suites/data/15/preferred +0 -2
- package/test/suites/data/16/descr +0 -1
- package/test/suites/data/16/merged +0 -2
- package/test/suites/data/16/other +0 -2
- package/test/suites/data/16/preferred +0 -2
- package/test/suites/data/17/descr +0 -1
- package/test/suites/data/17/merged +0 -2
- package/test/suites/data/17/other +0 -2
- package/test/suites/data/17/preferred +0 -2
- package/test/suites/data/18/descr +0 -1
- package/test/suites/data/18/merged +0 -2
- package/test/suites/data/18/other +0 -2
- package/test/suites/data/18/preferred +0 -2
- package/test/suites/data/19/descr +0 -1
- package/test/suites/data/19/merged +0 -2
- package/test/suites/data/19/other +0 -2
- package/test/suites/data/19/preferred +0 -2
- package/test/suites/data/2/merged +0 -3
- package/test/suites/data/2/other +0 -2
- package/test/suites/data/2/preferred +0 -3
- package/test/suites/data/20/descr +0 -1
- package/test/suites/data/20/merged +0 -3
- package/test/suites/data/20/other +0 -2
- package/test/suites/data/20/preferred +0 -2
- package/test/suites/data/21/descr +0 -1
- package/test/suites/data/21/merged +0 -4
- package/test/suites/data/21/other +0 -4
- package/test/suites/data/21/preferred +0 -3
- package/test/suites/data/22/descr +0 -1
- package/test/suites/data/22/merged +0 -10
- package/test/suites/data/22/other +0 -7
- package/test/suites/data/22/preferred +0 -10
- package/test/suites/data/23/descr +0 -1
- package/test/suites/data/23/merged +0 -2
- package/test/suites/data/23/other +0 -2
- package/test/suites/data/23/preferred +0 -2
- package/test/suites/data/24/descr +0 -1
- package/test/suites/data/24/merged +0 -2
- package/test/suites/data/24/other +0 -2
- package/test/suites/data/24/preferred +0 -2
- package/test/suites/data/25/descr +0 -1
- package/test/suites/data/25/merged +0 -2
- package/test/suites/data/25/other +0 -2
- package/test/suites/data/25/preferred +0 -2
- package/test/suites/data/26/descr +0 -1
- package/test/suites/data/26/merged +0 -3
- package/test/suites/data/26/other +0 -3
- package/test/suites/data/26/preferred +0 -3
- package/test/suites/data/27/merged +0 -3
- package/test/suites/data/27/other +0 -2
- package/test/suites/data/27/preferred +0 -2
- package/test/suites/data/28/merged +0 -3
- package/test/suites/data/28/other +0 -2
- package/test/suites/data/28/preferred +0 -2
- package/test/suites/data/29/merged +0 -2
- package/test/suites/data/29/other +0 -2
- package/test/suites/data/29/preferred +0 -2
- package/test/suites/data/3/merged +0 -3
- package/test/suites/data/3/other +0 -3
- package/test/suites/data/3/preferred +0 -3
- package/test/suites/data/30/merged +0 -3
- package/test/suites/data/30/other +0 -2
- package/test/suites/data/30/preferred +0 -2
- package/test/suites/data/31/merged +0 -3
- package/test/suites/data/31/other +0 -2
- package/test/suites/data/31/preferred +0 -3
- package/test/suites/data/32/other +0 -2
- package/test/suites/data/32/preferred +0 -3
- package/test/suites/data/33/merged +0 -2
- package/test/suites/data/33/other +0 -2
- package/test/suites/data/33/preferred +0 -2
- package/test/suites/data/34/merged +0 -2
- package/test/suites/data/34/other +0 -2
- package/test/suites/data/34/preferred +0 -2
- package/test/suites/data/35/merged +0 -2
- package/test/suites/data/35/other +0 -2
- package/test/suites/data/35/preferred +0 -2
- package/test/suites/data/36/merged +0 -2
- package/test/suites/data/36/other +0 -2
- package/test/suites/data/36/preferred +0 -2
- package/test/suites/data/37/merged +0 -3
- package/test/suites/data/37/other +0 -2
- package/test/suites/data/37/preferred +0 -2
- package/test/suites/data/38/merged +0 -3
- package/test/suites/data/38/other +0 -2
- package/test/suites/data/38/preferred +0 -2
- package/test/suites/data/39/merged +0 -2
- package/test/suites/data/39/other +0 -2
- package/test/suites/data/39/preferred +0 -2
- package/test/suites/data/4/descr +0 -1
- package/test/suites/data/4/merged +0 -2
- package/test/suites/data/4/other +0 -2
- package/test/suites/data/4/preferred +0 -2
- package/test/suites/data/40/merged +0 -2
- package/test/suites/data/40/other +0 -2
- package/test/suites/data/40/preferred +0 -2
- package/test/suites/data/41/merged +0 -2
- package/test/suites/data/41/other +0 -2
- package/test/suites/data/41/preferred +0 -2
- package/test/suites/data/42/merged +0 -2
- package/test/suites/data/42/other +0 -2
- package/test/suites/data/42/preferred +0 -2
- package/test/suites/data/43/merged +0 -2
- package/test/suites/data/43/other +0 -2
- package/test/suites/data/43/preferred +0 -2
- package/test/suites/data/44/merged +0 -2
- package/test/suites/data/44/other +0 -2
- package/test/suites/data/44/preferred +0 -2
- package/test/suites/data/45/merged +0 -2
- package/test/suites/data/45/other +0 -2
- package/test/suites/data/45/preferred +0 -2
- package/test/suites/data/46/merged +0 -2
- package/test/suites/data/46/other +0 -2
- package/test/suites/data/46/preferred +0 -2
- package/test/suites/data/47/merged +0 -2
- package/test/suites/data/47/other +0 -2
- package/test/suites/data/47/preferred +0 -2
- package/test/suites/data/48/merged +0 -2
- package/test/suites/data/48/other +0 -2
- package/test/suites/data/48/preferred +0 -2
- package/test/suites/data/49/merged +0 -3
- package/test/suites/data/49/other +0 -2
- package/test/suites/data/49/preferred +0 -2
- package/test/suites/data/5/descr +0 -1
- package/test/suites/data/5/merged +0 -2
- package/test/suites/data/5/other +0 -2
- package/test/suites/data/5/preferred +0 -2
- package/test/suites/data/50/merged +0 -3
- package/test/suites/data/50/other +0 -2
- package/test/suites/data/50/preferred +0 -2
- package/test/suites/data/51/merged +0 -3
- package/test/suites/data/51/other +0 -2
- package/test/suites/data/51/preferred +0 -2
- package/test/suites/data/52/merged +0 -2
- package/test/suites/data/52/other +0 -2
- package/test/suites/data/52/preferred +0 -2
- package/test/suites/data/53/merged +0 -3
- package/test/suites/data/53/other +0 -2
- package/test/suites/data/53/preferred +0 -2
- package/test/suites/data/54/merged +0 -3
- package/test/suites/data/54/other +0 -2
- package/test/suites/data/54/preferred +0 -2
- package/test/suites/data/55/merged +0 -3
- package/test/suites/data/55/other +0 -2
- package/test/suites/data/55/preferred +0 -2
- package/test/suites/data/56/merged +0 -2
- package/test/suites/data/56/other +0 -2
- package/test/suites/data/56/preferred +0 -2
- package/test/suites/data/57/descr +0 -1
- package/test/suites/data/57/merged +0 -4
- package/test/suites/data/57/other +0 -4
- package/test/suites/data/57/preferred +0 -4
- package/test/suites/data/58/descr +0 -1
- package/test/suites/data/58/merged +0 -2
- package/test/suites/data/58/other +0 -2
- package/test/suites/data/58/preferred +0 -2
- package/test/suites/data/59/descr +0 -1
- package/test/suites/data/59/merged +0 -2
- package/test/suites/data/59/other +0 -2
- package/test/suites/data/59/preferred +0 -2
- package/test/suites/data/6/descr +0 -1
- package/test/suites/data/6/merged +0 -2
- package/test/suites/data/6/other +0 -3
- package/test/suites/data/6/preferred +0 -2
- package/test/suites/data/60/descr +0 -1
- package/test/suites/data/60/merged +0 -2
- package/test/suites/data/60/other +0 -2
- package/test/suites/data/60/preferred +0 -2
- package/test/suites/data/61/descr +0 -1
- package/test/suites/data/61/merged +0 -2
- package/test/suites/data/61/other +0 -2
- package/test/suites/data/61/preferred +0 -2
- package/test/suites/data/62/descr +0 -1
- package/test/suites/data/62/merged +0 -3
- package/test/suites/data/62/other +0 -2
- package/test/suites/data/62/preferred +0 -2
- package/test/suites/data/63/descr +0 -1
- package/test/suites/data/63/merged +0 -3
- package/test/suites/data/63/other +0 -2
- package/test/suites/data/63/preferred +0 -2
- package/test/suites/data/64/merged +0 -2
- package/test/suites/data/64/other +0 -2
- package/test/suites/data/64/preferred +0 -2
- package/test/suites/data/65/merged +0 -3
- package/test/suites/data/65/other +0 -2
- package/test/suites/data/65/preferred +0 -2
- package/test/suites/data/66/merged +0 -2
- package/test/suites/data/66/other +0 -2
- package/test/suites/data/66/preferred +0 -2
- package/test/suites/data/67/merged +0 -2
- package/test/suites/data/67/other +0 -2
- package/test/suites/data/67/preferred +0 -2
- package/test/suites/data/68/merged +0 -2
- package/test/suites/data/68/other +0 -2
- package/test/suites/data/68/preferred +0 -2
- package/test/suites/data/69/merged +0 -2
- package/test/suites/data/69/other +0 -2
- package/test/suites/data/69/preferred +0 -2
- package/test/suites/data/7/descr +0 -1
- package/test/suites/data/7/merged +0 -4
- package/test/suites/data/7/other +0 -3
- package/test/suites/data/7/preferred +0 -3
- package/test/suites/data/70/merged +0 -2
- package/test/suites/data/70/other +0 -2
- package/test/suites/data/70/preferred +0 -2
- package/test/suites/data/71/merged +0 -3
- package/test/suites/data/71/other +0 -2
- package/test/suites/data/71/preferred +0 -2
- package/test/suites/data/72/merged +0 -5
- package/test/suites/data/72/other +0 -2
- package/test/suites/data/72/preferred +0 -4
- package/test/suites/data/73/merged +0 -3
- package/test/suites/data/73/other +0 -3
- package/test/suites/data/73/preferred +0 -3
- package/test/suites/data/74/1/merged +0 -3
- package/test/suites/data/74/1/other +0 -3
- package/test/suites/data/74/1/preferred +0 -2
- package/test/suites/data/74/merged +0 -4
- package/test/suites/data/74/other +0 -4
- package/test/suites/data/74/preferred +0 -2
- package/test/suites/data/75/74/1/merged +0 -3
- package/test/suites/data/75/74/1/other +0 -3
- package/test/suites/data/75/74/1/preferred +0 -2
- package/test/suites/data/75/74/merged +0 -4
- package/test/suites/data/75/74/other +0 -4
- package/test/suites/data/75/74/preferred +0 -2
- package/test/suites/data/75/merged +0 -4
- package/test/suites/data/75/other +0 -3
- package/test/suites/data/75/preferred +0 -2
- package/test/suites/data/76/merged +0 -2
- package/test/suites/data/76/other +0 -2
- package/test/suites/data/76/preferred +0 -2
- package/test/suites/data/77/descr +0 -1
- package/test/suites/data/77/merged +0 -2
- package/test/suites/data/77/other +0 -2
- package/test/suites/data/77/preferred +0 -2
- package/test/suites/data/78/merged +0 -3
- package/test/suites/data/78/other +0 -2
- package/test/suites/data/78/preferred +0 -2
- package/test/suites/data/79/merged +0 -2
- package/test/suites/data/79/other +0 -2
- package/test/suites/data/79/preferred +0 -2
- package/test/suites/data/8/descr +0 -1
- package/test/suites/data/8/merged +0 -3
- package/test/suites/data/8/other +0 -3
- package/test/suites/data/8/preferred +0 -3
- package/test/suites/data/80/merged +0 -3
- package/test/suites/data/80/other +0 -2
- package/test/suites/data/80/preferred +0 -2
- package/test/suites/data/81/merged +0 -2
- package/test/suites/data/81/other +0 -2
- package/test/suites/data/81/preferred +0 -2
- package/test/suites/data/82/merged +0 -2
- package/test/suites/data/82/other +0 -2
- package/test/suites/data/82/preferred +0 -2
- package/test/suites/data/83/merged +0 -2
- package/test/suites/data/83/other +0 -2
- package/test/suites/data/83/preferred +0 -1
- package/test/suites/data/84/merged +0 -2
- package/test/suites/data/84/other +0 -2
- package/test/suites/data/84/preferred +0 -1
- package/test/suites/data/85/merged +0 -2
- package/test/suites/data/85/other +0 -2
- package/test/suites/data/85/preferred +0 -2
- package/test/suites/data/86/merged +0 -2
- package/test/suites/data/86/other +0 -2
- package/test/suites/data/86/preferred +0 -1
- package/test/suites/data/87/merged +0 -2
- package/test/suites/data/87/other +0 -2
- package/test/suites/data/87/preferred +0 -1
- package/test/suites/data/88/merged +0 -2
- package/test/suites/data/88/other +0 -2
- package/test/suites/data/88/preferred +0 -1
- package/test/suites/data/9/descr +0 -1
- package/test/suites/data/9/merged +0 -2
- package/test/suites/data/9/other +0 -2
- package/test/suites/data/9/preferred +0 -2
- package/test/test.js +0 -1001
package/test/test.js
DELETED
|
@@ -1,1001 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* A configurable Javascript module for merging MARC records
|
|
6
|
-
*
|
|
7
|
-
* Copyright (c) 2015-2017 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of marc-record-merge
|
|
10
|
-
*
|
|
11
|
-
* marc-record-merge 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
|
-
* This program 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
|
-
**/
|
|
28
|
-
|
|
29
|
-
(function (root, factory) {
|
|
30
|
-
|
|
31
|
-
'use strict';
|
|
32
|
-
if (typeof define === 'function' && define.amd) {
|
|
33
|
-
define([
|
|
34
|
-
'chai/chai',
|
|
35
|
-
'marc-record-js',
|
|
36
|
-
'../lib/main',
|
|
37
|
-
'@natlibfi/es6-shims/lib/shims/array'
|
|
38
|
-
], factory);
|
|
39
|
-
} else if (typeof module === 'object' && module.exports) {
|
|
40
|
-
module.exports = factory(
|
|
41
|
-
require('chai'),
|
|
42
|
-
require('marc-record-js'),
|
|
43
|
-
require('../lib/main'),
|
|
44
|
-
require('@natlibfi/es6-shims/lib/shims/array')
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
}(this, factory));
|
|
49
|
-
|
|
50
|
-
function factory(chai, MarcRecord, mergeFactory, shim_array)
|
|
51
|
-
{
|
|
52
|
-
|
|
53
|
-
'use strict';
|
|
54
|
-
|
|
55
|
-
return function(getResources)
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
function runSuite(name_data, name_config, doneCallback, plugins)
|
|
59
|
-
{
|
|
60
|
-
try {
|
|
61
|
-
getResources(name_data, name_config).then(function(resources) {
|
|
62
|
-
|
|
63
|
-
var record_preferred, record_other, record_merged;
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
record_preferred = MarcRecord.fromString(resources.data.preferred);
|
|
67
|
-
record_other = MarcRecord.fromString(resources.data.other);
|
|
68
|
-
record_merged = mergeFactory(resources.config, plugins)(record_preferred, record_other);
|
|
69
|
-
|
|
70
|
-
expect(record_merged.toString().trim()).to.equal(resources.data.merged.trim(), 'merged do not match');
|
|
71
|
-
expect(record_preferred.toString().trim()).to.equal(resources.data.preferred.trim(), 'preferreds do not match');
|
|
72
|
-
expect(record_other.toString().trim()).to.equal(resources.data.other.trim(), 'others do not match');
|
|
73
|
-
|
|
74
|
-
doneCallback();
|
|
75
|
-
|
|
76
|
-
} catch (e_inner) {
|
|
77
|
-
doneCallback(e_inner);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
}, function (error) {
|
|
81
|
-
doneCallback(error);
|
|
82
|
-
});
|
|
83
|
-
} catch (e) {
|
|
84
|
-
doneCallback(e);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
var expect = chai.expect;
|
|
89
|
-
|
|
90
|
-
describe('factory', function() {
|
|
91
|
-
|
|
92
|
-
it('Should be a function', function() {
|
|
93
|
-
expect(mergeFactory).to.be.a('function');
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('Should return a function', function() {
|
|
97
|
-
expect(function() {
|
|
98
|
-
|
|
99
|
-
mergeFactory({
|
|
100
|
-
fields: []
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
}).to.be.a('function');
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('Should return a function with empty plugins', function() {
|
|
107
|
-
expect(mergeFactory({
|
|
108
|
-
fields: []
|
|
109
|
-
}, {
|
|
110
|
-
plugins: {}
|
|
111
|
-
})).to.be.a('function');
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
describe('object', function() {
|
|
117
|
-
|
|
118
|
-
it('Should apply plugins', function() {
|
|
119
|
-
expect(function() {
|
|
120
|
-
mergeFactory({
|
|
121
|
-
fields: {
|
|
122
|
-
'...': {
|
|
123
|
-
action: 'foobar'
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}, {
|
|
127
|
-
actions: {
|
|
128
|
-
foobar: function(record_merged, record_other, options, comparators) {
|
|
129
|
-
comparators.fooBar();
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
comparators: {
|
|
133
|
-
fooBar: function() {}
|
|
134
|
-
}
|
|
135
|
-
})(
|
|
136
|
-
new MarcRecord({
|
|
137
|
-
fields: [{
|
|
138
|
-
tag: '001',
|
|
139
|
-
value: 'foo'
|
|
140
|
-
}]
|
|
141
|
-
}),
|
|
142
|
-
new MarcRecord({
|
|
143
|
-
fields: [{
|
|
144
|
-
tag: '001',
|
|
145
|
-
value: 'bar'
|
|
146
|
-
}]
|
|
147
|
-
})
|
|
148
|
-
);
|
|
149
|
-
}).to.not.throw();
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
describe('merge', function() {
|
|
155
|
-
|
|
156
|
-
it('Should fail because of non-existing action', function() {
|
|
157
|
-
expect(function() {
|
|
158
|
-
mergeFactory({
|
|
159
|
-
fields: {
|
|
160
|
-
'...': {
|
|
161
|
-
action: 'foobar'
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
})(
|
|
165
|
-
new MarcRecord({
|
|
166
|
-
fields: [{
|
|
167
|
-
tag: '001',
|
|
168
|
-
value: 'foo'
|
|
169
|
-
}]
|
|
170
|
-
}),
|
|
171
|
-
new MarcRecord({
|
|
172
|
-
fields: [{
|
|
173
|
-
tag: '001',
|
|
174
|
-
value: 'bar'
|
|
175
|
-
}]
|
|
176
|
-
})
|
|
177
|
-
);
|
|
178
|
-
}).to.throw(Error, /^Undefined action \'foobar\'$/);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
it("Should be copied from other record if it's not present in preferred record", function(done) {
|
|
182
|
-
runSuite('1', '1to3', done);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it("Should be kept if missing from from other record", function(done) {
|
|
186
|
-
runSuite('2', '1to3', done);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it("Should take it from preferred record if both records have it", function(done) {
|
|
190
|
-
runSuite('3', '1to3', done);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it("Should not copy the field from other record because indicators do not match (Indicator 2)", function(done) {
|
|
194
|
-
runSuite('74', '1to3', done);
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
it("Should not copy the field from other record because indicators do not match (Indicator 1)", function(done) {
|
|
198
|
-
runSuite('75', '1to3', done);
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it("Should use the field with more information is used", function(done) {
|
|
202
|
-
runSuite('4', '4to26', done);
|
|
203
|
-
});
|
|
204
|
-
it("Should keep only one copy of identical fields in the merged record", function(done) {
|
|
205
|
-
runSuite('5', '4to26', done);
|
|
206
|
-
});
|
|
207
|
-
it("Should only copy fields that are configured", function(done) {
|
|
208
|
-
runSuite('6', '4to26', done);
|
|
209
|
-
});
|
|
210
|
-
it("Should copy whole field instead of merging specifically configured subfields if the fields are not identical", function(done) {
|
|
211
|
-
runSuite('7', '4to26', done);
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
it("Should copy because copyIf matches", function(done) {
|
|
215
|
-
runSuite('78', '78to79', done);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it("Should not copy because copyIf does not match", function(done) {
|
|
219
|
-
runSuite('79', '78to79', done);
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it("Should copy because copyUnless does not match", function(done) {
|
|
223
|
-
runSuite('80', '80to81', done);
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it("Should not copy because copyUnless matches", function(done) {
|
|
227
|
-
runSuite('81', '80to81', done);
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it("Should copy field from other record and discard from preferred", function(done) {
|
|
231
|
-
runSuite('82', '82', done);
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it("It should keep matched subfield", function(done) {
|
|
235
|
-
runSuite('83', '83to85', done);
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it("It should drop unmatched subfields", function(done) {
|
|
239
|
-
runSuite('84', '83to85', done);
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
it("It should keep subfields from preferred", function(done) {
|
|
243
|
-
runSuite('85', '83to85', done);
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it("It should keep exactly matched subfield", function(done) {
|
|
247
|
-
runSuite('86', '86', done);
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
it("It should keep unmatched subfield", function(done) {
|
|
251
|
-
runSuite('87', '87', done);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it("It should keep exactly unmatched subfield", function(done) {
|
|
255
|
-
runSuite('88', '88', done);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it("Should move specifically configured subfields if the fields are identical (sans configured subfields)", function(done) {
|
|
259
|
-
runSuite('8', '4to26', done);
|
|
260
|
-
});
|
|
261
|
-
it("Should normalize for comparison but preserve diacritics in copy action", function(done) {
|
|
262
|
-
runSuite('9', '4to26', done);
|
|
263
|
-
});
|
|
264
|
-
it("Should normalize for comparison but preserve diacritics in move subfields action", function(done) {
|
|
265
|
-
runSuite('10', '4to26', done);
|
|
266
|
-
});
|
|
267
|
-
it("Should normalize case for comparison but preserve it in copy action", function(done) {
|
|
268
|
-
runSuite('11', '4to26', done);
|
|
269
|
-
});
|
|
270
|
-
it("Should normalize punctuation for comparison but preserve it in move subfields action", function(done) {
|
|
271
|
-
runSuite('12', '4to26', done);
|
|
272
|
-
});
|
|
273
|
-
it("Should handle controlfields correctly", function(done) {
|
|
274
|
-
runSuite('13', '4to26', done);
|
|
275
|
-
});
|
|
276
|
-
it("Should select better field from preferred record", function(done) {
|
|
277
|
-
runSuite('14', '4to26', done);
|
|
278
|
-
});
|
|
279
|
-
it("Should select better field from other record", function(done) {
|
|
280
|
-
runSuite('15', '4to26', done);
|
|
281
|
-
});
|
|
282
|
-
it("Should select better field from other record, making comparison without 'compareWithout' subfields.", function(done) {
|
|
283
|
-
runSuite('16', '4to26', done);
|
|
284
|
-
});
|
|
285
|
-
it("Should move only one instance of 'compareWithout' fields to merged", function(done) {
|
|
286
|
-
runSuite('17', '4to26', done);
|
|
287
|
-
});
|
|
288
|
-
it("Should select better field from preferred record, making comparison without 'compareWithout' subfields.", function(done) {
|
|
289
|
-
runSuite('18', '4to26', done);
|
|
290
|
-
});
|
|
291
|
-
it("Should handle e subfields in field 700 with compareWithout setting.", function(done) {
|
|
292
|
-
runSuite('19', '4to26', done);
|
|
293
|
-
});
|
|
294
|
-
it("Should handle e subfields with compareWithout setting.", function(done) {
|
|
295
|
-
runSuite('20', '4to26', done);
|
|
296
|
-
});
|
|
297
|
-
it("Should copy field from the preferred record and include b-subfield only from the preferred field because the subfield are compared as normalized", function(done) {
|
|
298
|
-
runSuite('77', '77', done);
|
|
299
|
-
});
|
|
300
|
-
it("Should not mess up any fields.", function(done) {
|
|
301
|
-
runSuite('21', '4to26', done);
|
|
302
|
-
});
|
|
303
|
-
it("Should not mess up any fields.", function(done) {
|
|
304
|
-
runSuite('22', '4to26', done);
|
|
305
|
-
});
|
|
306
|
-
it("Should use field from other record if the preferred record is proper subset. Note that only fields that have been marked in config will be handled.", function(done) {
|
|
307
|
-
runSuite('23', '4to26', done);
|
|
308
|
-
});
|
|
309
|
-
it("Should compare without indicators if compareWithoutIndicators options is true. Selects the field with most indicators.", function(done) {
|
|
310
|
-
runSuite('24', '4to26', done);
|
|
311
|
-
});
|
|
312
|
-
it("Should compare without indicators if compareWithoutIndicators options is true. Selects the field with most indicators.", function(done) {
|
|
313
|
-
runSuite('25', '4to26', done);
|
|
314
|
-
});
|
|
315
|
-
it("Should only make superset comparisons when identical fields are not present.", function(done) {
|
|
316
|
-
runSuite('26', '4to26', done);
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
it("Should move field matching regex", function(done) {
|
|
320
|
-
runSuite('27', '27to28', done);
|
|
321
|
-
});
|
|
322
|
-
it("Should move fields matching regex", function(done) {
|
|
323
|
-
runSuite('28', '27to28', done);
|
|
324
|
-
});
|
|
325
|
-
it("Should not copy field from other if preferred already has one", function(done) {
|
|
326
|
-
runSuite('29', '29to31', done);
|
|
327
|
-
});
|
|
328
|
-
it("Should copy field from other if preferred doesn't have one", function(done) {
|
|
329
|
-
runSuite('30', '29to31', done);
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
it("Should keep data from preferred if other doesn't have it", function(done) {
|
|
333
|
-
runSuite('31', '29to31', done);
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
it("Should select the field that has more subfields using substring comparison of field equality", function(done) {
|
|
337
|
-
getResources('32', '32to40').then(function(resources) {
|
|
338
|
-
try {
|
|
339
|
-
|
|
340
|
-
var record_preferred = MarcRecord.fromString(resources.data.preferred);
|
|
341
|
-
var record_other = MarcRecord.fromString(resources.data.other);
|
|
342
|
-
|
|
343
|
-
expect(function() {
|
|
344
|
-
mergeFactory(resources.config)(record_preferred, record_other);
|
|
345
|
-
}).to.throw(/^selectBetter cannot be used if there are multiple fields of same tag/);
|
|
346
|
-
|
|
347
|
-
done();
|
|
348
|
-
|
|
349
|
-
} catch (e ) {
|
|
350
|
-
done(e);
|
|
351
|
-
}
|
|
352
|
-
}, done);
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
it("SelectBetter option should not create a copy of identical fields", function(done) {
|
|
356
|
-
runSuite('33', '32to40', done);
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
it("SelectBetter option should not create a copy of non-identical fields and it should use the one in preferred if neither is subset", function(done) {
|
|
360
|
-
runSuite('34', '32to40', done);
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
it("SelectBetter option should use the field from other record if it's a superset", function(done) {
|
|
364
|
-
runSuite('35', '32to40', done);
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
it("SelectBetter option should use the field from preferred record if it's a superset", function(done) {
|
|
368
|
-
runSuite('36', '32to40', done);
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
it("SelectBetter should copy the field from other if it's missing from preferred", function(done) {
|
|
372
|
-
runSuite('37', '32to40', done);
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
it("SelectBetter should keep the field from preferred if it's missing from other", function(done) {
|
|
376
|
-
runSuite('38', '32to40', done);
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
it("Should select the field that has more subfields using substring comparison of field equality", function(done) {
|
|
380
|
-
runSuite('39', '32to40', done);
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
it("Should select the field that has better subfields if the fields have equal sets of subfields using substring comparator", function(done) {
|
|
384
|
-
runSuite('40', '32to40', done);
|
|
385
|
-
});
|
|
386
|
-
it("Should select the field from other when it has more subfields", function(done) {
|
|
387
|
-
runSuite('41', '41to43', done);
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
it("Should select the field from preferred when it has more subfields", function(done) {
|
|
391
|
-
runSuite('42', '41to43', done);
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
it("Should not select the field from other when there is no field in preferred", function(done) {
|
|
395
|
-
runSuite('43', '41to43', done);
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
it("Should combine identical ISBN fields into a single one.", function(done) {
|
|
399
|
-
runSuite('44', '44to56', done);
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
it("Should compare ISBN field equality without q-subfield.", function(done) {
|
|
403
|
-
runSuite('45', '44to56', done);
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
it("Should merge multiple different q-subfields to the same field. ", function(done) {
|
|
407
|
-
runSuite('46', '44to56', done);
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
it("Should create an array of c subfields if there are multiple different ones.", function(done) {
|
|
411
|
-
runSuite('47', '44to56', done);
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
it("Should merge multiple similar z-subfields.", function(done) {
|
|
415
|
-
runSuite('48', '44to56', done);
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
it("Should keep all of the subfields", function(done) {
|
|
419
|
-
runSuite('49', '44to56', done);
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
it("Should not make multiple isbn fields from similar items", function(done) {
|
|
423
|
-
runSuite('50', '44to56', done);
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
it("Should not make multiple isbn fields from similar items", function(done) {
|
|
427
|
-
runSuite('51', '44to56', done);
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
it("Should merge multiple different z-subfields to the same field. ", function(done) {
|
|
431
|
-
runSuite('52', '44to56', done);
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
it("Should not merge multiple different z,q-subfields to the same field when a-subfield is missing.", function(done) {
|
|
435
|
-
runSuite('53', '44to56', done);
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
it("Should merge multiple different z-subfields to the same field. ", function(done) {
|
|
439
|
-
runSuite('54', '44to56', done);
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
it("Should not merge multiple fields if all of the subfields are marked as compareWithout", function(done) {
|
|
443
|
-
runSuite('55', '44to56', done);
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
it("Should create an array of c subfields if there are multiple different ones.", function(done) {
|
|
447
|
-
runSuite('56', '44to56', done);
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
it("Should not mess up any fields.", function(done) {
|
|
451
|
-
runSuite('57', '57to63', done);
|
|
452
|
-
});
|
|
453
|
-
it("SelectBetter option should not create a copy of identical fields.", function(done) {
|
|
454
|
-
runSuite('58', '57to63', done);
|
|
455
|
-
});
|
|
456
|
-
it("SelectBetter option should not create a copy of non-identical fields and it should use the one in preferred if neither is subset.", function(done) {
|
|
457
|
-
runSuite('59', '57to63', done);
|
|
458
|
-
});
|
|
459
|
-
it("SelectBetter option should use the field from other record if it's a superset", function(done) {
|
|
460
|
-
runSuite('60', '57to63', done);
|
|
461
|
-
});
|
|
462
|
-
it("SelectBetter option should use the field from preferred record if it's a superset", function(done) {
|
|
463
|
-
runSuite('61', '57to63', done);
|
|
464
|
-
});
|
|
465
|
-
it("SelectBetter should copy the field from other if it's missing from preferred.", function(done) {
|
|
466
|
-
runSuite('62', '57to63', done);
|
|
467
|
-
});
|
|
468
|
-
it("SelectBetter should keep the field from preferred if it's missing from other.", function(done) {
|
|
469
|
-
runSuite('63', '57to63', done);
|
|
470
|
-
});
|
|
471
|
-
|
|
472
|
-
it("Should use custom action", function(done) {
|
|
473
|
-
|
|
474
|
-
function customAction(record_merged, field_other, options)
|
|
475
|
-
{
|
|
476
|
-
|
|
477
|
-
record_merged.fields = record_merged.fields.filter(function(field) {
|
|
478
|
-
return field.tag !== '100';
|
|
479
|
-
});
|
|
480
|
-
|
|
481
|
-
field_other.wasUsed = true;
|
|
482
|
-
field_other.fromOther = true;
|
|
483
|
-
record_merged.fields.push(field_other);
|
|
484
|
-
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
runSuite('64', '64', done, {
|
|
488
|
-
actions: {
|
|
489
|
-
chooseField100FromOther: customAction
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
|
|
493
|
-
});
|
|
494
|
-
|
|
495
|
-
it('It should transform a copied field', function(done) {
|
|
496
|
-
runSuite('65', '65', done);
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
it('It should pick fields from the other field that is not copied to the merged record', function(done) {
|
|
500
|
-
runSuite('66', '66', done);
|
|
501
|
-
});
|
|
502
|
-
|
|
503
|
-
it('It should pick only missing fields from the other field that is not copied to the merged record', function(done) {
|
|
504
|
-
runSuite('67', '67', done);
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
it('It should pick fields from the other field to the preferred field that is considered better', function(done) {
|
|
508
|
-
runSuite('68', '68', done);
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
it('It should pick fields from the preferred field to the other field that is considered better', function(done) {
|
|
512
|
-
runSuite('69', '69', done);
|
|
513
|
-
});
|
|
514
|
-
|
|
515
|
-
it('It should pick only missing fields from the other field to the preferred field that is considered better', function(done) {
|
|
516
|
-
runSuite('70', '70', done);
|
|
517
|
-
});
|
|
518
|
-
|
|
519
|
-
it('Should insert new content before the similar field', function(done) {
|
|
520
|
-
runSuite('71', '71', done);
|
|
521
|
-
});
|
|
522
|
-
|
|
523
|
-
it('Should insert new content according to specified sort index', function(done) {
|
|
524
|
-
runSuite('72', '72', done);
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
it("Should keep the preferred field instead of selecting the better one because 'skipOnMultiple' is true", function(done) {
|
|
528
|
-
runSuite('73', '73', done);
|
|
529
|
-
});
|
|
530
|
-
|
|
531
|
-
it("Should create new field based on field in other record", function() {
|
|
532
|
-
var record_preferred =
|
|
533
|
-
"LDR ^^^^^cam^a2200637zi^4500";
|
|
534
|
-
|
|
535
|
-
var record_other =
|
|
536
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
537
|
-
"020 ‡a978-952-67417-9-6";
|
|
538
|
-
|
|
539
|
-
var record_expected =
|
|
540
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
541
|
-
"720 12 ‡z9789526741796‡b123";
|
|
542
|
-
|
|
543
|
-
var config = { "fields": { "020": { "action": "createFrom", "options": { "convertTag": "720", "ind1": "1", "ind2": "2", "subfields": { "a": { "convertCode": "z", "modifications": [ { "type": "replace", "args": [/-/g, ""] } ] }, "b": { "replaceValue": "123" } } } } } };
|
|
544
|
-
|
|
545
|
-
var record_preferred_obj = MarcRecord.fromString(record_preferred);
|
|
546
|
-
var record_other_obj = MarcRecord.fromString(record_other);
|
|
547
|
-
|
|
548
|
-
var record_merged = mergeFactory(config)(record_preferred_obj, record_other_obj);
|
|
549
|
-
|
|
550
|
-
expect(record_merged.toString().trim()).to.equal(record_expected.trim(), 'merged do not match');
|
|
551
|
-
expect(record_preferred_obj.toString().trim()).to.equal(record_preferred.trim(), 'preferreds do not match');
|
|
552
|
-
expect(record_other_obj.toString().trim()).to.equal(record_other.trim(), 'others do not match');
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
it("Should add new subfield to existing field using field in other record", function() {
|
|
556
|
-
var record_preferred =
|
|
557
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
558
|
-
"773 ‡7p1am";
|
|
559
|
-
|
|
560
|
-
var record_other =
|
|
561
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
562
|
-
"100 1 ‡aAbcd";
|
|
563
|
-
|
|
564
|
-
var record_expected =
|
|
565
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
566
|
-
"773 ‡7p1am‡aAbcd";
|
|
567
|
-
|
|
568
|
-
var config = { "fields": { "100": { "action": "createFrom", "options": { "convertTag": "773", "useExisting": true, "subfields": { "a": {} } } } } };
|
|
569
|
-
|
|
570
|
-
var record_preferred_obj = MarcRecord.fromString(record_preferred);
|
|
571
|
-
var record_other_obj = MarcRecord.fromString(record_other);
|
|
572
|
-
|
|
573
|
-
var record_merged = mergeFactory(config)(record_preferred_obj, record_other_obj);
|
|
574
|
-
|
|
575
|
-
expect(record_merged.toString().trim()).to.equal(record_expected.trim(), 'merged do not match');
|
|
576
|
-
expect(record_preferred_obj.toString().trim()).to.equal(record_preferred.trim(), 'preferreds do not match');
|
|
577
|
-
expect(record_other_obj.toString().trim()).to.equal(record_other.trim(), 'others do not match');
|
|
578
|
-
});
|
|
579
|
-
|
|
580
|
-
it("Should create new field based on field in other record using custom function", function() {
|
|
581
|
-
var record_preferred =
|
|
582
|
-
"LDR ^^^^^cam^a2200637zi^4500";
|
|
583
|
-
|
|
584
|
-
var record_other =
|
|
585
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
586
|
-
"020 ‡a1234567890";
|
|
587
|
-
|
|
588
|
-
var record_expected =
|
|
589
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
590
|
-
"020 ‡a0987654321";
|
|
591
|
-
|
|
592
|
-
var reverseString = function(str) {
|
|
593
|
-
if (str === "")
|
|
594
|
-
return "";
|
|
595
|
-
else
|
|
596
|
-
return reverseString(str.substr(1)) + str.charAt(0);
|
|
597
|
-
};
|
|
598
|
-
|
|
599
|
-
var config = { "fields": { "020": { "action": "createFrom", "options": { "subfields": { "a": { "modifications": [ reverseString ] } } } } } };
|
|
600
|
-
|
|
601
|
-
var record_preferred_obj = MarcRecord.fromString(record_preferred);
|
|
602
|
-
var record_other_obj = MarcRecord.fromString(record_other);
|
|
603
|
-
|
|
604
|
-
var record_merged = mergeFactory(config)(record_preferred_obj, record_other_obj);
|
|
605
|
-
|
|
606
|
-
expect(record_merged.toString().trim()).to.equal(record_expected.trim(), 'merged do not match');
|
|
607
|
-
expect(record_preferred_obj.toString().trim()).to.equal(record_preferred.trim(), 'preferreds do not match');
|
|
608
|
-
expect(record_other_obj.toString().trim()).to.equal(record_other.trim(), 'others do not match');
|
|
609
|
-
});
|
|
610
|
-
|
|
611
|
-
it("Should add new subfield to existing field keeping field in other record", function() {
|
|
612
|
-
var record_preferred =
|
|
613
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
614
|
-
"773 ‡7p1am";
|
|
615
|
-
|
|
616
|
-
var record_other =
|
|
617
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
618
|
-
"100 ‡aAbcd";
|
|
619
|
-
|
|
620
|
-
var record_expected =
|
|
621
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
622
|
-
"773 ‡7p1am" + "\n" +
|
|
623
|
-
"773 ‡aAbcd";
|
|
624
|
-
|
|
625
|
-
var config = { "fields": { "100": { "action": "createFrom", "options": { "convertTag": "773", "keepExisting": true, "subfields": { "a": {} } } } } };
|
|
626
|
-
|
|
627
|
-
var record_preferred_obj = MarcRecord.fromString(record_preferred);
|
|
628
|
-
var record_other_obj = MarcRecord.fromString(record_other);
|
|
629
|
-
|
|
630
|
-
var record_merged = mergeFactory(config)(record_preferred_obj, record_other_obj);
|
|
631
|
-
|
|
632
|
-
expect(record_merged.toString().trim()).to.equal(record_expected.trim(), 'merged do not match');
|
|
633
|
-
expect(record_preferred_obj.toString().trim()).to.equal(record_preferred.trim(), 'preferreds do not match');
|
|
634
|
-
expect(record_other_obj.toString().trim()).to.equal(record_other.trim(), 'others do not match');
|
|
635
|
-
});
|
|
636
|
-
|
|
637
|
-
it("Should add new field with subfield concatenating two subfields together", function() {
|
|
638
|
-
var record_preferred =
|
|
639
|
-
"LDR ^^^^^cam^a2200637zi^4500";
|
|
640
|
-
|
|
641
|
-
var record_other =
|
|
642
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
643
|
-
"260 ‡aabc‡bdef";
|
|
644
|
-
|
|
645
|
-
var record_expected =
|
|
646
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
647
|
-
"773 ‡dabcdef";
|
|
648
|
-
|
|
649
|
-
var config = { "fields": { "260": { "action": "createFrom", "options": { "convertTag": "773", "subfields": { "a": { "convertCode": "d", "append": true }, "b": { "convertCode": "d", "append": true } } } } } };
|
|
650
|
-
|
|
651
|
-
var record_preferred_obj = MarcRecord.fromString(record_preferred);
|
|
652
|
-
var record_other_obj = MarcRecord.fromString(record_other);
|
|
653
|
-
|
|
654
|
-
var record_merged = mergeFactory(config)(record_preferred_obj, record_other_obj);
|
|
655
|
-
|
|
656
|
-
expect(record_merged.toString().trim()).to.equal(record_expected.trim(), 'merged do not match');
|
|
657
|
-
expect(record_preferred_obj.toString().trim()).to.equal(record_preferred.trim(), 'preferreds do not match');
|
|
658
|
-
expect(record_other_obj.toString().trim()).to.equal(record_other.trim(), 'others do not match');
|
|
659
|
-
});
|
|
660
|
-
|
|
661
|
-
it("Should fail to add new field with subfield concatenating two subfields together", function() {
|
|
662
|
-
var record_preferred =
|
|
663
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
664
|
-
"773 ‡dabc‡ddef";
|
|
665
|
-
|
|
666
|
-
var record_other =
|
|
667
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
668
|
-
"260 ‡aghi";
|
|
669
|
-
|
|
670
|
-
var config = { "fields": { "260": { "action": "createFrom", "options": { "useExisting": true, "convertTag": "773", "subfields": { "a": { "convertCode": "d", "append": true } } } } } };
|
|
671
|
-
|
|
672
|
-
expect(function() {
|
|
673
|
-
mergeFactory(config)(MarcRecord.fromString(record_preferred), MarcRecord.fromString(record_other));
|
|
674
|
-
}).to.throw(Error, /^append option cannot be used if there are multiple subfields of same code\.$/);
|
|
675
|
-
});
|
|
676
|
-
|
|
677
|
-
it("Should modify field based on field in other record", function() {
|
|
678
|
-
var record_preferred =
|
|
679
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
680
|
-
"300 ‡a1 verkkoaineisto (XXX sivua)";
|
|
681
|
-
|
|
682
|
-
var record_other =
|
|
683
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
684
|
-
"300 ‡a83 s.";
|
|
685
|
-
|
|
686
|
-
var record_expected =
|
|
687
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
688
|
-
"300 ‡a1 Verkkoaineisto (83 sivua) a";
|
|
689
|
-
|
|
690
|
-
var config = { "fields": { "300": { "action": "createFrom", "options": { "subfields": { "a": { "modifications": [ { "type": "replace", "args": [/ s\./, " sivua"] }, { "type": "wrap", "args": [ "(", ")" ] }, { "type": "prepend", "args": [ "1 Verkkoaineisto " ] }, { "type": "append", "args": [ " a" ] } ] } } } } } };
|
|
691
|
-
|
|
692
|
-
var record_preferred_obj = MarcRecord.fromString(record_preferred);
|
|
693
|
-
var record_other_obj = MarcRecord.fromString(record_other);
|
|
694
|
-
|
|
695
|
-
var record_merged = mergeFactory(config)(record_preferred_obj, record_other_obj);
|
|
696
|
-
|
|
697
|
-
expect(record_merged.toString().trim()).to.equal(record_expected.trim(), 'merged do not match');
|
|
698
|
-
expect(record_preferred_obj.toString().trim()).to.equal(record_preferred.trim(), 'preferreds do not match');
|
|
699
|
-
expect(record_other_obj.toString().trim()).to.equal(record_other.trim(), 'others do not match');
|
|
700
|
-
});
|
|
701
|
-
|
|
702
|
-
it("Should fail to modify field because unknown operation", function() {
|
|
703
|
-
var record_preferred =
|
|
704
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
705
|
-
"300 ‡a1 verkkoaineisto (XXX sivua)";
|
|
706
|
-
|
|
707
|
-
var record_other =
|
|
708
|
-
"LDR ^^^^^cam^a2200637zi^4500" + "\n" +
|
|
709
|
-
"300 ‡a83 s.";
|
|
710
|
-
|
|
711
|
-
var config = { "fields": { "300": { "action": "createFrom", "options": { "subfields": { "a": { "modifications": [ { "type": "unknown", "args": [/ s\./, " sivua"] } ] } } } } } };
|
|
712
|
-
|
|
713
|
-
expect(function() {
|
|
714
|
-
mergeFactory(config)(MarcRecord.fromString(record_preferred), MarcRecord.fromString(record_other));
|
|
715
|
-
}).to.throw(Error, /^Undefined string operation 'unknown'$/);
|
|
716
|
-
});
|
|
717
|
-
|
|
718
|
-
it("Should fail to select a better field because number of subfields are not equal", function() {
|
|
719
|
-
expect(function() {
|
|
720
|
-
mergeFactory({
|
|
721
|
-
fields: {
|
|
722
|
-
'245': {
|
|
723
|
-
action: 'selectBetter',
|
|
724
|
-
options: {
|
|
725
|
-
comparator: 'fooBar'
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
}, {
|
|
730
|
-
comparators: {
|
|
731
|
-
'fooBar': function() { return 1; }
|
|
732
|
-
}
|
|
733
|
-
})(
|
|
734
|
-
new MarcRecord({
|
|
735
|
-
fields: [{
|
|
736
|
-
tag: '245',
|
|
737
|
-
subfields: [{
|
|
738
|
-
code: 'a',
|
|
739
|
-
value: 'foo'
|
|
740
|
-
}]
|
|
741
|
-
}]
|
|
742
|
-
}),
|
|
743
|
-
new MarcRecord({
|
|
744
|
-
fields: [{
|
|
745
|
-
tag: '245',
|
|
746
|
-
subfields: [
|
|
747
|
-
{
|
|
748
|
-
code: 'a',
|
|
749
|
-
value: 'foo'
|
|
750
|
-
},
|
|
751
|
-
{
|
|
752
|
-
code: 'b',
|
|
753
|
-
value: 'bar'
|
|
754
|
-
}
|
|
755
|
-
]
|
|
756
|
-
}]
|
|
757
|
-
})
|
|
758
|
-
);
|
|
759
|
-
}).to.throw(Error, /^Number of subfields are not equal$/);
|
|
760
|
-
});
|
|
761
|
-
|
|
762
|
-
it("Should return the merged record and details about the merge process", function() {
|
|
763
|
-
|
|
764
|
-
var record_merged = new MarcRecord({
|
|
765
|
-
fields: [{
|
|
766
|
-
tag: '003',
|
|
767
|
-
value: 'CaOONL'
|
|
768
|
-
}]
|
|
769
|
-
}),
|
|
770
|
-
record_preferred = new MarcRecord({
|
|
771
|
-
fields: []
|
|
772
|
-
}),
|
|
773
|
-
record_other = new MarcRecord({
|
|
774
|
-
fields: [{
|
|
775
|
-
tag: '003',
|
|
776
|
-
value: 'CaOONL'
|
|
777
|
-
}]
|
|
778
|
-
}),
|
|
779
|
-
result = mergeFactory({
|
|
780
|
-
fields: {
|
|
781
|
-
'003': {
|
|
782
|
-
action: 'controlfield'
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
})(record_preferred, record_other, 1);
|
|
786
|
-
|
|
787
|
-
expect(result).to.be.an('object');
|
|
788
|
-
expect(result).to.have.all.keys(['record', 'details']);
|
|
789
|
-
expect(result.record.toString()).to.eql(record_merged.toString());
|
|
790
|
-
expect(result.details).to.eql({
|
|
791
|
-
'003': [{
|
|
792
|
-
action: 'controlfield',
|
|
793
|
-
index: 0
|
|
794
|
-
}]
|
|
795
|
-
});
|
|
796
|
-
|
|
797
|
-
});
|
|
798
|
-
|
|
799
|
-
it('Should return details on multiple fields', function() {
|
|
800
|
-
var result = mergeFactory({
|
|
801
|
-
fields: {
|
|
802
|
-
'...': {
|
|
803
|
-
action: 'copy'
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
})(
|
|
807
|
-
new MarcRecord({
|
|
808
|
-
fields: [{
|
|
809
|
-
tag: '001',
|
|
810
|
-
value: 'foo'
|
|
811
|
-
}]
|
|
812
|
-
}),
|
|
813
|
-
new MarcRecord({
|
|
814
|
-
fields: [
|
|
815
|
-
{
|
|
816
|
-
tag: '100',
|
|
817
|
-
subfields: [{
|
|
818
|
-
code: 'a',
|
|
819
|
-
value: 'foo'
|
|
820
|
-
}]
|
|
821
|
-
},
|
|
822
|
-
{
|
|
823
|
-
tag: '100',
|
|
824
|
-
subfields: [{
|
|
825
|
-
code: 'a',
|
|
826
|
-
value: 'bar'
|
|
827
|
-
}]
|
|
828
|
-
}
|
|
829
|
-
]
|
|
830
|
-
}),
|
|
831
|
-
1
|
|
832
|
-
);
|
|
833
|
-
|
|
834
|
-
expect(JSON.parse(JSON.stringify(result))).to.eql({
|
|
835
|
-
record: {
|
|
836
|
-
fields: [
|
|
837
|
-
{
|
|
838
|
-
tag: '001',
|
|
839
|
-
value: 'foo',
|
|
840
|
-
fromPreferred: true,
|
|
841
|
-
wasUsed: true
|
|
842
|
-
},
|
|
843
|
-
{
|
|
844
|
-
tag: '100',
|
|
845
|
-
subfields: [{
|
|
846
|
-
code: 'a',
|
|
847
|
-
value: 'foo'
|
|
848
|
-
}],
|
|
849
|
-
fromOther: true,
|
|
850
|
-
wasUsed: true
|
|
851
|
-
},
|
|
852
|
-
{
|
|
853
|
-
tag: '100',
|
|
854
|
-
subfields: [{
|
|
855
|
-
code: 'a',
|
|
856
|
-
value: 'bar'
|
|
857
|
-
}],
|
|
858
|
-
fromOther: true,
|
|
859
|
-
wasUsed: true
|
|
860
|
-
}
|
|
861
|
-
]
|
|
862
|
-
},
|
|
863
|
-
details: {
|
|
864
|
-
100: [
|
|
865
|
-
{
|
|
866
|
-
action: 'copy'
|
|
867
|
-
},
|
|
868
|
-
{
|
|
869
|
-
action: 'copy'
|
|
870
|
-
}
|
|
871
|
-
]
|
|
872
|
-
}
|
|
873
|
-
});
|
|
874
|
-
|
|
875
|
-
});
|
|
876
|
-
|
|
877
|
-
describe("mergeControlfield", function() {
|
|
878
|
-
var preferred, other;
|
|
879
|
-
var config = {
|
|
880
|
-
"fields": {
|
|
881
|
-
"008": {
|
|
882
|
-
"action": "mergeControlfield",
|
|
883
|
-
"options": {
|
|
884
|
-
"actions": [
|
|
885
|
-
{
|
|
886
|
-
"formats": ["BK", "CF", "CR", "MU", "MX", "VM", "MP"],
|
|
887
|
-
"range": [15, 17],
|
|
888
|
-
"significantCaret": false,
|
|
889
|
-
"type": "selectNonEmpty"
|
|
890
|
-
},
|
|
891
|
-
{
|
|
892
|
-
"formats": ["BK", "CF", "CR", "MU", "MX", "VM", "MP"],
|
|
893
|
-
"range": [35, 37],
|
|
894
|
-
"significantCaret": false,
|
|
895
|
-
"type": "selectNonEmpty"
|
|
896
|
-
},
|
|
897
|
-
{
|
|
898
|
-
"formats": ["BK"],
|
|
899
|
-
"range": [18, 21],
|
|
900
|
-
"significantCaret": true,
|
|
901
|
-
"type": "combine"
|
|
902
|
-
}
|
|
903
|
-
]
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
};
|
|
908
|
-
function selectValue(tag, record) {
|
|
909
|
-
var field = shim_array.find(record.fields, function(field) { return field.tag === tag; });
|
|
910
|
-
if (field) {
|
|
911
|
-
return field.value;
|
|
912
|
-
}
|
|
913
|
-
return undefined;
|
|
914
|
-
}
|
|
915
|
-
function setType(chars, leader) {
|
|
916
|
-
return leader.substr(0,6) + chars + leader.substr(8);
|
|
917
|
-
}
|
|
918
|
-
function prime008Fields(preferredValue, otherValue) {
|
|
919
|
-
preferred.appendControlField(['008', preferredValue]);
|
|
920
|
-
other.appendControlField(['008', otherValue]);
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
function primeTypes(preferredType, otherType) {
|
|
924
|
-
|
|
925
|
-
var typeChars = {
|
|
926
|
-
'BK': 'am',
|
|
927
|
-
'MU': 'cm'
|
|
928
|
-
};
|
|
929
|
-
|
|
930
|
-
preferred.leader = setType(typeChars[preferredType], preferred.leader);
|
|
931
|
-
other.leader = setType(typeChars[otherType], other.leader);
|
|
932
|
-
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
beforeEach(function() {
|
|
936
|
-
preferred = new MarcRecord();
|
|
937
|
-
other = new MarcRecord();
|
|
938
|
-
|
|
939
|
-
preferred.leader = "00000cam^a2200733^i^4500";
|
|
940
|
-
other.leader = "00000cam^a2200733^i^4500";
|
|
941
|
-
});
|
|
942
|
-
|
|
943
|
-
function selectMerged008Value() {
|
|
944
|
-
var merged = mergeFactory(config, [])(preferred, other);
|
|
945
|
-
return selectValue('008', merged);
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
it("should pick value form other if preferred is empty", function() {
|
|
949
|
-
primeTypes('BK', 'BK');
|
|
950
|
-
prime008Fields(
|
|
951
|
-
'861000s1972^^^^||||||||||||||||||||eng||',
|
|
952
|
-
'861000s1972^^^^xxu|||||||||||||||||eng||'
|
|
953
|
-
);
|
|
954
|
-
|
|
955
|
-
expect(selectMerged008Value()).to.equal('861000s1972^^^^xxu|||||||||||||||||eng||');
|
|
956
|
-
});
|
|
957
|
-
|
|
958
|
-
it("should not do anything if record types are different", function() {
|
|
959
|
-
primeTypes('BK', 'MU');
|
|
960
|
-
prime008Fields(
|
|
961
|
-
'861000s1972^^^^||||||||||||||||||||eng||',
|
|
962
|
-
'861000s1972^^^^xxu|||||||||||||||||eng||'
|
|
963
|
-
);
|
|
964
|
-
|
|
965
|
-
expect(selectMerged008Value()).to.equal('861000s1972^^^^||||||||||||||||||||eng||');
|
|
966
|
-
});
|
|
967
|
-
|
|
968
|
-
it("should combine fragment when action type is combine", function() {
|
|
969
|
-
primeTypes('BK', 'BK');
|
|
970
|
-
prime008Fields(
|
|
971
|
-
'861000s1972^^^^|||abc||||||||||||||eng||',
|
|
972
|
-
'861000s1972^^^^|||abe||||||||||||||eng||'
|
|
973
|
-
);
|
|
974
|
-
|
|
975
|
-
expect(selectMerged008Value()).to.equal('861000s1972^^^^|||abce|||||||||||||eng||');
|
|
976
|
-
});
|
|
977
|
-
|
|
978
|
-
it("should not convert uncoded fragment to empty fragment", function() {
|
|
979
|
-
primeTypes('BK', 'BK');
|
|
980
|
-
prime008Fields(
|
|
981
|
-
'861000s1972^^^^||||||||||||||||||||eng||',
|
|
982
|
-
'861000s1972^^^^||||||||||||||||||||eng||'
|
|
983
|
-
);
|
|
984
|
-
|
|
985
|
-
expect(selectMerged008Value()).to.equal('861000s1972^^^^||||||||||||||||||||eng||');
|
|
986
|
-
});
|
|
987
|
-
it("should fill combined fragment with empty characters", function() {
|
|
988
|
-
primeTypes('BK', 'BK');
|
|
989
|
-
prime008Fields(
|
|
990
|
-
'861000s1972^^^^|||c||||||||||||||||eng||',
|
|
991
|
-
'861000s1972^^^^|||ae|||||||||||||||eng||'
|
|
992
|
-
);
|
|
993
|
-
|
|
994
|
-
expect(selectMerged008Value()).to.equal('861000s1972^^^^|||ace^|||||||||||||eng||');
|
|
995
|
-
});
|
|
996
|
-
});
|
|
997
|
-
});
|
|
998
|
-
|
|
999
|
-
};
|
|
1000
|
-
|
|
1001
|
-
}
|