@natlibfi/marc-record-merge 6.0.0-beta.1 → 6.0.0-beta.11
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/.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 +122 -2
- package/dist/index.js +56 -42
- package/dist/index.js.map +1 -1
- package/dist/index.spec.js +59 -0
- package/dist/index.spec.js.map +1 -0
- package/dist/reducers/copy.js +254 -80
- package/dist/reducers/copy.js.map +1 -1
- package/dist/reducers/copy.spec.js +57 -72
- package/dist/reducers/copy.spec.js.map +1 -1
- package/dist/reducers/copy2.spec.js +67 -0
- package/dist/reducers/copy2.spec.js.map +1 -0
- package/dist/reducers/index.js +13 -24
- package/dist/reducers/index.js.map +1 -1
- package/dist/reducers/select.js +63 -58
- package/dist/reducers/select.js.map +1 -1
- package/dist/reducers/select.spec.js +45 -92
- package/dist/reducers/select.spec.js.map +1 -1
- package/dist/reducers/select2.spec.js +58 -0
- package/dist/reducers/select2.spec.js.map +1 -0
- package/package.json +33 -32
- package/src/index.js +50 -32
- package/src/index.spec.js +45 -0
- package/src/reducers/copy.js +262 -80
- package/src/reducers/copy.spec.js +50 -48
- package/src/reducers/copy2.spec.js +55 -0
- package/src/reducers/index.js +3 -30
- package/src/reducers/select.js +53 -39
- package/src/reducers/select.spec.js +41 -56
- package/src/reducers/select2.spec.js +49 -0
- package/test-fixtures/index/01/base.json +24 -0
- package/test-fixtures/index/01/merged.json +24 -0
- package/test-fixtures/index/01/metadata.json +8 -0
- package/test-fixtures/index/01/source.json +40 -0
- package/test-fixtures/index/02/base.json +24 -0
- package/test-fixtures/index/02/merged.json +24 -0
- package/test-fixtures/index/02/metadata.json +7 -0
- package/test-fixtures/index/02/source.json +40 -0
- package/test-fixtures/reducers/copy/{01/base.json → 01 - copy/01/base.json } +1 -1
- package/test-fixtures/reducers/copy/{01 → 01 - copy/01}/merged.json +0 -0
- package/test-fixtures/reducers/copy/01 - copy/01/metadata.json +4 -0
- package/test-fixtures/reducers/copy/{01 → 01 - copy/01}/source.json +0 -0
- package/test-fixtures/reducers/copy/{02/source.json → 01 - copy/02/base.json} +0 -0
- package/test-fixtures/reducers/copy/{02 → 01 - copy/02}/merged.json +0 -0
- package/test-fixtures/reducers/copy/01 - copy/02/metadata.json +4 -0
- package/test-fixtures/reducers/copy/{02/base.json → 01 - copy/02/source.json } +1 -1
- package/test-fixtures/reducers/copy/{03/base.json → 01 - copy/03/base.json } +1 -1
- package/test-fixtures/reducers/copy/{03 → 01 - copy/03}/merged.json +0 -0
- package/test-fixtures/reducers/copy/01 - copy/03/metadata.json +4 -0
- package/test-fixtures/reducers/copy/{03 → 01 - copy/03}/source.json +0 -0
- package/test-fixtures/reducers/copy/{05/base.json → 01 - copy/04/base.json } +1 -1
- package/test-fixtures/reducers/copy/{04/merged.json → 01 - copy/04/merged.json } +1 -1
- package/test-fixtures/reducers/copy/01 - copy/04/metadata.json +4 -0
- package/test-fixtures/reducers/copy/{04/source.json → 01 - copy/04/source.json } +1 -1
- package/test-fixtures/reducers/copy/{04/base.json → 01 - copy/05/base.json } +1 -1
- package/test-fixtures/reducers/copy/01 - copy/05/merged.json +77 -0
- package/test-fixtures/reducers/copy/01 - copy/05/metadata.json +4 -0
- package/test-fixtures/reducers/copy/01 - copy/05/source.json +62 -0
- package/test-fixtures/reducers/copy/01 - copy/06/base.json +24 -0
- package/test-fixtures/reducers/copy/01 - copy/06/merged.json +39 -0
- package/test-fixtures/reducers/copy/01 - copy/06/metadata.json +4 -0
- package/test-fixtures/reducers/copy/01 - copy/06/source.json +24 -0
- package/test-fixtures/reducers/copy/01 - copy/07/base.json +39 -0
- package/test-fixtures/reducers/copy/01 - copy/07/merged.json +39 -0
- package/test-fixtures/reducers/copy/01 - copy/07/metadata.json +5 -0
- package/test-fixtures/reducers/copy/01 - copy/07/source.json +24 -0
- package/test-fixtures/reducers/copy/01 - copy/08/base.json +28 -0
- package/test-fixtures/reducers/copy/01 - copy/08/merged.json +28 -0
- package/test-fixtures/reducers/copy/01 - copy/08/metadata.json +4 -0
- package/test-fixtures/reducers/copy/01 - copy/08/source.json +24 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/base.json +17 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/merged.json +20 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/metadata.json +6 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/01/source.json +20 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/base.json +9 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/merged.json +20 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/metadata.json +6 -0
- package/test-fixtures/reducers/copy/02 - doNotCopyIfFieldPresent/02/source.json +20 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/base.json +24 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/merged.json +24 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/metadata.json +5 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/01/source.json +24 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/base.json +24 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/merged.json +100 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/metadata.json +5 -0
- package/test-fixtures/reducers/copy/03 - compareTagsOnly/02/source.json +100 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/base.json +24 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/merged.json +24 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/metadata.json +5 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/01/source.json +24 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/base.json +24 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/merged.json +39 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/metadata.json +5 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/02/source.json +24 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/03/metadata.json +6 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/04/base.json +20 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/04/merged.json +31 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/04/metadata.json +5 -0
- package/test-fixtures/reducers/copy/04 - compareWithoutIndicators/04/source.json +20 -0
- package/test-fixtures/reducers/copy/05 - copyUnless/01/base.json +9 -0
- package/test-fixtures/reducers/copy/05 - copyUnless/01/merged.json +24 -0
- package/test-fixtures/reducers/copy/05 - copyUnless/01/metadata.json +5 -0
- package/test-fixtures/reducers/copy/05 - copyUnless/01/source.json +47 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/base.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/merged.json +39 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/01/source.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/base.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/merged.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/02/source.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/base.json +28 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/merged.json +43 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/03/source.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/base.json +28 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/merged.json +28 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/04/source.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/base.json +20 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/merged.json +35 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/05/source.json +24 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/base.json +20 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/merged.json +35 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/metadata.json +5 -0
- package/test-fixtures/reducers/copy/06 - subfieldsMustBeIdentical/06/source.json +24 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/01/base.json +39 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/01/merged.json +39 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/01/metadata.json +8 -0
- package/test-fixtures/reducers/copy/{05/source.json → 07 - excludeSubfields/01/source.json } +1 -1
- package/test-fixtures/reducers/copy/07 - excludeSubfields/02/base.json +39 -0
- package/test-fixtures/reducers/copy/{05/merged.json → 07 - excludeSubfields/02/merged.json } +5 -5
- package/test-fixtures/reducers/copy/07 - excludeSubfields/02/metadata.json +5 -0
- package/test-fixtures/reducers/copy/07 - excludeSubfields/02/source.json +43 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/01/base.json +35 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/01/merged.json +54 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/01/metadata.json +5 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/01/source.json +43 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/02/base.json +43 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/02/merged.json +58 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/02/metadata.json +5 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/02/source.json +32 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/03/base.json +43 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/03/merged.json +58 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/03/metadata.json +5 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/03/source.json +32 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/04/base.json +43 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/04/merged.json +43 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/04/metadata.json +5 -0
- package/test-fixtures/reducers/copy/08 - dropSubfields/04/source.json +32 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/base.json +9 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/merged.json +20 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/metadata.json +6 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/01/source.json +20 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/base.json +9 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/merged.json +20 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/metadata.json +6 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/02/source.json +20 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/base.json +9 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/merged.json +31 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/metadata.json +6 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/03/source.json +31 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/base.json +9 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/merged.json +42 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/metadata.json +6 -0
- package/test-fixtures/reducers/copy/09 - swapSubfieldCode/04/source.json +42 -0
- package/test-fixtures/reducers/copy/10 - swapTag/01/base.json +17 -0
- package/test-fixtures/reducers/copy/10 - swapTag/01/merged.json +28 -0
- package/test-fixtures/reducers/copy/10 - swapTag/01/metadata.json +6 -0
- package/test-fixtures/reducers/copy/10 - swapTag/01/source.json +20 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/01/base.json +28 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/01/merged.json +28 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/01/metadata.json +6 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/01/source.json +20 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/02/base.json +28 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/02/merged.json +39 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/02/metadata.json +6 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/02/source.json +31 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/03/base.json +28 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/03/merged.json +28 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/03/metadata.json +7 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/03/source.json +20 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/04/base.json +17 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/04/merged.json +28 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/04/metadata.json +7 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/04/source.json +31 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/05/base.json +28 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/05/merged.json +28 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/05/metadata.json +7 -0
- package/test-fixtures/reducers/copy/11 - compareWithoutTag/05/source.json +28 -0
- package/test-fixtures/reducers/metadata.json +4 -0
- package/test-fixtures/reducers/select/01/metadata.json +5 -0
- package/test-fixtures/reducers/select/02/metadata.json +4 -0
- package/test-fixtures/reducers/select/03/metadata.json +4 -0
- package/test-fixtures/reducers/select/04/metadata.json +5 -0
- package/test-fixtures/reducers/select/05/metadata.json +4 -0
- package/test-fixtures/reducers/select/06/base.json +4 -0
- package/test-fixtures/reducers/select/06/merged.json +4 -0
- package/test-fixtures/reducers/select/06/metadata.json +4 -0
- package/test-fixtures/reducers/select/06/source.json +4 -0
- package/test-fixtures/reducers/select/07/metadata.json +5 -0
- package/test-fixtures/reducers/select/08/metadata.json +4 -0
- package/test-fixtures/reducers/select/09/metadata.json +4 -0
- package/test-fixtures/reducers/select/10/metadata.json +5 -0
- package/test-fixtures/reducers/select/11/metadata.json +4 -0
- package/test-fixtures/reducers/select/12/metadata.json +5 -0
- package/test-fixtures/reducers/select/13/metadata.json +4 -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/.drone.yml +0 -92
- package/.nyc_output/7ecda3cd-9f84-4416-a466-fa1e5889c6a3.json +0 -1
- package/.nyc_output/processinfo/7ecda3cd-9f84-4416-a466-fa1e5889c6a3.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/LICENSE.txt +0 -165
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -79
- package/coverage/copy.js.html +0 -344
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -126
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -79
- package/coverage/lcov-report/copy.js.html +0 -344
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -126
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/select.js.html +0 -431
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -170
- package/coverage/lcov.info +0 -195
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/select.js.html +0 -431
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -170
- package/test-fixtures/reducers/copy/01/pattern.txt +0 -1
- package/test-fixtures/reducers/copy/02/pattern.txt +0 -1
- package/test-fixtures/reducers/copy/03/pattern.txt +0 -1
- package/test-fixtures/reducers/copy/04/pattern.txt +0 -1
- package/test-fixtures/reducers/copy/05/pattern.txt +0 -1
- package/test-fixtures/reducers/select/01/expected-error.txt +0 -1
- package/test-fixtures/reducers/select/01/pattern.txt +0 -1
- package/test-fixtures/reducers/select/02/pattern.txt +0 -1
- package/test-fixtures/reducers/select/03/pattern.txt +0 -1
- package/test-fixtures/reducers/select/04/pattern.txt +0 -1
- package/test-fixtures/reducers/select/05/pattern.txt +0 -1
- package/test-fixtures/reducers/select/06/pattern.txt +0 -1
- package/test-fixtures/reducers/select/07/equalityFunction.txt +0 -1
- package/test-fixtures/reducers/select/07/pattern.txt +0 -1
- package/test-fixtures/reducers/select/08/pattern.txt +0 -1
- package/test-fixtures/reducers/select/09/pattern.txt +0 -1
- package/test-fixtures/reducers/select/10/equalityFunction.txt +0 -1
- package/test-fixtures/reducers/select/10/pattern.txt +0 -1
- package/test-fixtures/reducers/select/11/pattern.txt +0 -1
- package/test-fixtures/reducers/select/12/equalityFunction.txt +0 -1
- package/test-fixtures/reducers/select/12/pattern.txt +0 -1
- package/test-fixtures/reducers/select/13/pattern.txt +0 -1
|
@@ -1,52 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* Merge MARC records
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2015-2019 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of marc-record-merge-js
|
|
10
|
-
|
|
11
|
-
* marc-record-merge-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser 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-merge-js 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 Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Lesser 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
|
-
import chai from 'chai';
|
|
29
|
-
import fs from 'fs';
|
|
30
|
-
import path from 'path';
|
|
31
|
-
import {MarcRecord} from '@natlibfi/marc-record';
|
|
1
|
+
import {expect} from 'chai';
|
|
2
|
+
import {READERS} from '@natlibfi/fixura';
|
|
32
3
|
import createReducer from './copy';
|
|
33
|
-
import
|
|
34
|
-
|
|
35
|
-
MarcRecord.setValidationOptions({subfieldValues: false});
|
|
4
|
+
import generateTests from '@natlibfi/fixugen';
|
|
36
5
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const fixturesPath = path.join(__dirname, '..', '..', 'test-fixtures', 'reducers', 'copy');
|
|
6
|
+
//import createDebugLogger from 'debug'; // <---
|
|
7
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-merge/copy.spec.js'); // <---
|
|
40
8
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
});
|
|
9
|
+
generateTests({
|
|
10
|
+
callback,
|
|
11
|
+
path: [__dirname, '..', '..', 'test-fixtures', 'reducers', 'copy'],
|
|
12
|
+
useMetadataFile: true,
|
|
13
|
+
recurse: true,
|
|
14
|
+
fixura: {
|
|
15
|
+
reader: READERS.JSON,
|
|
16
|
+
failWhenNotFound: false
|
|
17
|
+
}
|
|
52
18
|
});
|
|
19
|
+
|
|
20
|
+
function callback({
|
|
21
|
+
getFixture,
|
|
22
|
+
tagPatternRegExp,
|
|
23
|
+
compareTagsOnly = false,
|
|
24
|
+
compareWithoutTag = false,
|
|
25
|
+
compareWithoutIndicators = false,
|
|
26
|
+
compareWithoutIndicator1 = false,
|
|
27
|
+
compareWithoutIndicator2 = false,
|
|
28
|
+
subfieldsMustBeIdentical = false,
|
|
29
|
+
copyUnless = undefined,
|
|
30
|
+
excludeSubfields = undefined,
|
|
31
|
+
dropSubfields = undefined,
|
|
32
|
+
swapSubfieldCode = [],
|
|
33
|
+
swapTag = [],
|
|
34
|
+
doNotCopyIfFieldPresent = false
|
|
35
|
+
}) {
|
|
36
|
+
const base = getFixture('base.json');
|
|
37
|
+
const source = getFixture('source.json');
|
|
38
|
+
const tagPattern = new RegExp(tagPatternRegExp, 'u');
|
|
39
|
+
const expectedRecord = getFixture('merged.json');
|
|
40
|
+
|
|
41
|
+
const merged = createReducer({
|
|
42
|
+
tagPattern, compareTagsOnly, compareWithoutTag, compareWithoutIndicators, compareWithoutIndicator1, compareWithoutIndicator2,
|
|
43
|
+
copyUnless, subfieldsMustBeIdentical, excludeSubfields,
|
|
44
|
+
dropSubfields, swapSubfieldCode, swapTag,
|
|
45
|
+
doNotCopyIfFieldPresent
|
|
46
|
+
})(base, source);
|
|
47
|
+
//debug(`*** mergedRecord: `, mergedRecord); //<--
|
|
48
|
+
//debug(`*** mergedRecord,Strfy: `, JSON.stringify(mergedRecord)); //<--
|
|
49
|
+
//debug(`*** expectedRecord: `, expectedRecord); //<--
|
|
50
|
+
//debug(`*** expectedRecord,Strfy: `, JSON.stringify(expectedRecord)); //<--
|
|
51
|
+
expect(merged.constructor.name).not.to.eql('MarcRecord');
|
|
52
|
+
expect(merged.constructor.name).to.eql('Object');
|
|
53
|
+
expect(merged).to.eql(expectedRecord);
|
|
54
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {expect} from 'chai';
|
|
2
|
+
import {READERS} from '@natlibfi/fixura';
|
|
3
|
+
import createReducer from './copy';
|
|
4
|
+
import generateTests from '@natlibfi/fixugen';
|
|
5
|
+
|
|
6
|
+
//import createDebugLogger from 'debug'; // <---
|
|
7
|
+
//const debug = createDebugLogger('@natlibfi/marc-record-merge/copy.spec.js'); // <---
|
|
8
|
+
|
|
9
|
+
generateTests({
|
|
10
|
+
callback,
|
|
11
|
+
path: [__dirname, '..', '..', 'test-fixtures', 'reducers', 'copy'],
|
|
12
|
+
useMetadataFile: true,
|
|
13
|
+
recurse: true,
|
|
14
|
+
fixura: {
|
|
15
|
+
reader: READERS.JSON,
|
|
16
|
+
failWhenNotFound: false
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
function callback({
|
|
22
|
+
getFixture,
|
|
23
|
+
tagPatternRegExp,
|
|
24
|
+
compareTagsOnly = false,
|
|
25
|
+
compareWithoutTag = false,
|
|
26
|
+
compareWithoutIndicators = false,
|
|
27
|
+
compareWithoutIndicator1 = false,
|
|
28
|
+
compareWithoutIndicator2 = false,
|
|
29
|
+
subfieldsMustBeIdentical = false,
|
|
30
|
+
copyUnless = undefined,
|
|
31
|
+
excludeSubfields = undefined,
|
|
32
|
+
dropSubfields = undefined,
|
|
33
|
+
swapSubfieldCode = [],
|
|
34
|
+
swapTag = [],
|
|
35
|
+
doNotCopyIfFieldPresent = false
|
|
36
|
+
}) {
|
|
37
|
+
const base = getFixture('base.json');
|
|
38
|
+
const source = getFixture('source.json');
|
|
39
|
+
const tagPattern = new RegExp(tagPatternRegExp, 'u');
|
|
40
|
+
const expectedRecord = getFixture('merged.json');
|
|
41
|
+
|
|
42
|
+
const merged = createReducer({
|
|
43
|
+
tagPattern, compareTagsOnly, compareWithoutTag, compareWithoutIndicators, compareWithoutIndicator1, compareWithoutIndicator2,
|
|
44
|
+
copyUnless, subfieldsMustBeIdentical, excludeSubfields,
|
|
45
|
+
dropSubfields, swapSubfieldCode, swapTag,
|
|
46
|
+
doNotCopyIfFieldPresent
|
|
47
|
+
})({base, source});
|
|
48
|
+
//debug(`*** mergedRecord: `, mergedRecord); //<--
|
|
49
|
+
//debug(`*** mergedRecord,Strfy: `, JSON.stringify(mergedRecord)); //<--
|
|
50
|
+
//debug(`*** expectedRecord: `, expectedRecord); //<--
|
|
51
|
+
//debug(`*** expectedRecord,Strfy: `, JSON.stringify(expectedRecord)); //<--
|
|
52
|
+
expect(merged.constructor.name).not.to.eql('MarcRecord');
|
|
53
|
+
expect(merged.constructor.name).to.eql('Object');
|
|
54
|
+
expect(merged).to.eql(expectedRecord);
|
|
55
|
+
}
|
package/src/reducers/index.js
CHANGED
|
@@ -1,31 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* Merge MARC records
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2015-2019 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of marc-record-merge-js
|
|
10
|
-
|
|
11
|
-
* marc-record-merge-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser 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-merge-js 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 Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Lesser 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
|
-
export * from './copy';
|
|
30
|
-
export * from './select';
|
|
1
|
+
import copy from './copy';
|
|
2
|
+
import select, {strictEquality, subsetEquality} from './select';
|
|
31
3
|
|
|
4
|
+
export default {copy, select, strictEquality, subsetEquality};
|
package/src/reducers/select.js
CHANGED
|
@@ -1,57 +1,62 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* Merge MARC records
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2015-2019 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of marc-record-merge-js
|
|
10
|
-
|
|
11
|
-
* marc-record-merge-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser 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-merge-js 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 Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Lesser 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
1
|
import {normalizeSync} from 'normalize-diacritics';
|
|
2
|
+
import createDebugLogger from 'debug';
|
|
3
|
+
import {MarcRecord} from '@natlibfi/marc-record';
|
|
29
4
|
|
|
30
5
|
export function strictEquality(subfieldA, subfieldB) {
|
|
31
6
|
return subfieldA.code === subfieldB.code &&
|
|
32
|
-
|
|
7
|
+
subfieldA.value === subfieldB.value;
|
|
33
8
|
}
|
|
34
9
|
|
|
35
10
|
export function subsetEquality(subfieldA, subfieldB) {
|
|
36
11
|
return subfieldA.code === subfieldB.code &&
|
|
37
|
-
|
|
12
|
+
(subfieldA.value.indexOf(subfieldB.value) !== -1 || subfieldB.value.indexOf(subfieldA.value) !== -1);
|
|
38
13
|
}
|
|
14
|
+
// EqualityFunction can be either strictEquality or subsetEquality
|
|
15
|
+
|
|
16
|
+
export default ({
|
|
17
|
+
tagPattern,
|
|
18
|
+
equalityFunction = strictEquality,
|
|
19
|
+
baseValidators = {subfieldValues: false},
|
|
20
|
+
sourceValidators = {subfieldValues: false}
|
|
21
|
+
// eslint-disable-next-line max-statements
|
|
22
|
+
}) => (base, source) => {
|
|
23
|
+
const debug = createDebugLogger('@natlibfi/marc-record-merge:select');
|
|
24
|
+
|
|
25
|
+
const {baseRecord, sourceRecord} = getRecordsFromParameters(base, source, baseValidators, sourceValidators);
|
|
26
|
+
|
|
27
|
+
function getRecordsFromParameters(base, source, baseValidators, sourceValidators) {
|
|
28
|
+
// records if we got an object ({base, source}) as a parameter
|
|
29
|
+
if (source === undefined && base.base !== undefined && base.source !== undefined) {
|
|
30
|
+
const baseRecord = new MarcRecord(base.base, baseValidators);
|
|
31
|
+
const sourceRecord = new MarcRecord(base.source, sourceValidators);
|
|
32
|
+
return {baseRecord, sourceRecord};
|
|
33
|
+
}
|
|
34
|
+
// records if we got an non-object (base, source) as a parameter
|
|
35
|
+
const baseRecord = new MarcRecord(base, baseValidators);
|
|
36
|
+
const sourceRecord = new MarcRecord(source, sourceValidators);
|
|
37
|
+
return {baseRecord, sourceRecord};
|
|
38
|
+
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
const
|
|
40
|
+
const baseFields = baseRecord.get(tagPattern);
|
|
41
|
+
const sourceFields = sourceRecord.get(tagPattern);
|
|
42
|
+
const fieldTag = sourceFields.map(field => field.tag);
|
|
43
|
+
debug(`Comparing field ${fieldTag}`);
|
|
43
44
|
|
|
44
45
|
checkFieldType(baseFields);
|
|
45
46
|
checkFieldType(sourceFields);
|
|
46
47
|
|
|
47
48
|
if (baseFields.length > 1 || sourceFields.length > 1) {
|
|
48
|
-
|
|
49
|
+
debug(`Multiple fields in base or source`);
|
|
50
|
+
debug(`No changes to base`);
|
|
51
|
+
return baseRecord.toObject();
|
|
49
52
|
}
|
|
50
53
|
const [baseField] = baseFields;
|
|
51
54
|
const [sourceField] = sourceFields;
|
|
52
55
|
|
|
53
56
|
if (baseField.tag === sourceField.tag === false) {
|
|
54
|
-
|
|
57
|
+
debug(`Base tag ${baseField.tag} is not equal to source tag ${sourceField.tag}`);
|
|
58
|
+
debug(`No changes to base`);
|
|
59
|
+
return baseRecord.toObject();
|
|
55
60
|
}
|
|
56
61
|
const baseSubs = baseField.subfields;
|
|
57
62
|
const sourceSubs = sourceField.subfields;
|
|
@@ -62,19 +67,26 @@ export default ({pattern, equalityFunction = strictEquality}) => (base, source)
|
|
|
62
67
|
const sourceSubsNormalized = sourceSubs
|
|
63
68
|
.map(({code, value}) => ({code, value: normalizeSubfieldValue(value)}));
|
|
64
69
|
|
|
70
|
+
// Returns the base subfields for which a matching source subfield is found
|
|
65
71
|
const equalSubfieldsBase = baseSubsNormalized
|
|
66
72
|
.filter(baseSubfield => sourceSubsNormalized
|
|
67
73
|
.some(sourceSubfield => equalityFunction(baseSubfield, sourceSubfield)));
|
|
74
|
+
debug(`equalSubfieldsBase: ${JSON.stringify(equalSubfieldsBase, undefined, 2)}`);
|
|
68
75
|
|
|
76
|
+
// Returns the source subfields for which a matching base subfield is found
|
|
69
77
|
const equalSubfieldsSource = sourceSubsNormalized
|
|
70
78
|
.filter(sourceSubfield => baseSubsNormalized
|
|
71
79
|
.some(baseSubfield => equalityFunction(sourceSubfield, baseSubfield)));
|
|
80
|
+
debug(`equalSubfieldsSource: ${JSON.stringify(equalSubfieldsSource, undefined, 2)}`);
|
|
72
81
|
|
|
73
82
|
if (baseSubs.length === sourceSubs.length && equalSubfieldsBase.length < baseSubs.length) {
|
|
74
|
-
|
|
83
|
+
debug(`Base and source subfields are not equal`);
|
|
84
|
+
debug(`No changes to base`);
|
|
85
|
+
return baseRecord.toObject();
|
|
75
86
|
}
|
|
76
87
|
|
|
77
88
|
if (baseSubs.length === sourceSubs.length && equalSubfieldsBase.length === equalSubfieldsSource.length) {
|
|
89
|
+
debug(`Checking subfield equality`);
|
|
78
90
|
const totalSubfieldLengthBase = baseSubsNormalized
|
|
79
91
|
.map(({value}) => value.length)
|
|
80
92
|
.reduce((acc, value) => acc + value);
|
|
@@ -83,19 +95,21 @@ export default ({pattern, equalityFunction = strictEquality}) => (base, source)
|
|
|
83
95
|
.reduce((acc, value) => acc + value);
|
|
84
96
|
|
|
85
97
|
if (totalSubfieldLengthSource > totalSubfieldLengthBase) {
|
|
86
|
-
return replaceBasefieldWithSourcefield(
|
|
98
|
+
return replaceBasefieldWithSourcefield(baseRecord.toObject());
|
|
87
99
|
}
|
|
88
100
|
}
|
|
89
101
|
|
|
90
102
|
if (sourceSubs.length > baseSubs.length && equalSubfieldsBase.length === baseSubs.length) {
|
|
91
|
-
return replaceBasefieldWithSourcefield(
|
|
103
|
+
return replaceBasefieldWithSourcefield(baseRecord.toObject());
|
|
92
104
|
}
|
|
93
105
|
|
|
94
|
-
|
|
106
|
+
debug(`No changes to base`);
|
|
107
|
+
return baseRecord.toObject();
|
|
95
108
|
|
|
96
109
|
function replaceBasefieldWithSourcefield(base) {
|
|
97
110
|
const index = base.fields.findIndex(field => field === baseField);
|
|
98
111
|
base.fields.splice(index, 1, sourceField); // eslint-disable-line functional/immutable-data
|
|
112
|
+
debug(`Source field is longer, replacing base with source`);
|
|
99
113
|
return base;
|
|
100
114
|
}
|
|
101
115
|
|
|
@@ -111,7 +125,7 @@ export default ({pattern, equalityFunction = strictEquality}) => (base, source)
|
|
|
111
125
|
|
|
112
126
|
function normalizeSubfieldValue(value) {
|
|
113
127
|
// Regexp options: g: global search, u: unicode
|
|
114
|
-
const punctuation = /[
|
|
128
|
+
const punctuation = /[.,\-/#!?$%^&*;:{}=_`~()[\]]/gu;
|
|
115
129
|
return normalizeSync(value).toLowerCase().replace(punctuation, '', 'u').replace(/\s+/gu, ' ').trim();
|
|
116
130
|
}
|
|
117
131
|
};
|
|
@@ -1,64 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* @licstart The following is the entire license notice for the JavaScript code in this file.
|
|
4
|
-
*
|
|
5
|
-
* Merge MARC records
|
|
6
|
-
*
|
|
7
|
-
* Copyright (C) 2015-2019 University Of Helsinki (The National Library Of Finland)
|
|
8
|
-
*
|
|
9
|
-
* This file is part of marc-record-merge-js
|
|
10
|
-
|
|
11
|
-
* marc-record-merge-js program is free software: you can redistribute it and/or modify
|
|
12
|
-
* it under the terms of the GNU Lesser 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-merge-js 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 Lesser General Public License for more details.
|
|
20
|
-
*
|
|
21
|
-
* You should have received a copy of the GNU Lesser 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
|
-
import chai from 'chai';
|
|
29
|
-
import fs from 'fs';
|
|
30
|
-
import path from 'path';
|
|
1
|
+
import {expect} from 'chai';
|
|
31
2
|
import {MarcRecord} from '@natlibfi/marc-record';
|
|
32
3
|
import createReducer, {subsetEquality} from './select';
|
|
33
|
-
import
|
|
4
|
+
import {READERS} from '@natlibfi/fixura';
|
|
5
|
+
import generateTests from '@natlibfi/fixugen';
|
|
34
6
|
|
|
35
7
|
MarcRecord.setValidationOptions({subfieldValues: false});
|
|
36
8
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
9
|
+
generateTests({
|
|
10
|
+
callback,
|
|
11
|
+
path: [__dirname, '..', '..', 'test-fixtures', 'reducers', 'select'],
|
|
12
|
+
useMetadataFile: true,
|
|
13
|
+
recurse: false,
|
|
14
|
+
fixura: {
|
|
15
|
+
reader: READERS.JSON,
|
|
16
|
+
failWhenNotFound: false
|
|
17
|
+
}
|
|
18
|
+
});
|
|
40
19
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
20
|
+
function callback({
|
|
21
|
+
getFixture,
|
|
22
|
+
disabled = false,
|
|
23
|
+
tagPatternRegExp = false,
|
|
24
|
+
expectedError = false,
|
|
25
|
+
useSubsetEquality = false
|
|
26
|
+
}) {
|
|
27
|
+
if (disabled) {
|
|
28
|
+
console.log('TEST DISABLED!'); // eslint-disable-line no-console
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// const base = new MarcRecord(getFixture('base.json'), {subfieldValues: false});
|
|
32
|
+
// const source = new MarcRecord(getFixture('source.json'), {subfieldValues: false});
|
|
50
33
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const mergedRecord = createReducer({pattern: patternTest, equalityFunction})(baseTest, sourceTest);
|
|
56
|
-
expect(mergedRecord.toObject()).to.eql(expectedRecord);
|
|
34
|
+
const base = getFixture('base.json');
|
|
35
|
+
const source = getFixture('source.json');
|
|
57
36
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
37
|
+
const tagPattern = new RegExp(tagPatternRegExp, 'u');
|
|
38
|
+
const expectedRecord = getFixture('merged.json');
|
|
39
|
+
const equalityFunction = useSubsetEquality ? subsetEquality : undefined;
|
|
40
|
+
|
|
41
|
+
// Bypass expected error in testing
|
|
42
|
+
if (expectedError) {
|
|
43
|
+
expect(() => createReducer.to.throw(Error, 'control field'));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const mergedRecord = createReducer({tagPattern, equalityFunction})(base, source);
|
|
48
|
+
expect(mergedRecord).to.eql(expectedRecord);
|
|
49
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {expect} from 'chai';
|
|
2
|
+
import {MarcRecord} from '@natlibfi/marc-record';
|
|
3
|
+
import createReducer, {subsetEquality} from './select';
|
|
4
|
+
import {READERS} from '@natlibfi/fixura';
|
|
5
|
+
import generateTests from '@natlibfi/fixugen';
|
|
6
|
+
|
|
7
|
+
MarcRecord.setValidationOptions({subfieldValues: false});
|
|
8
|
+
|
|
9
|
+
generateTests({
|
|
10
|
+
callback,
|
|
11
|
+
path: [__dirname, '..', '..', 'test-fixtures', 'reducers', 'select'],
|
|
12
|
+
useMetadataFile: true,
|
|
13
|
+
recurse: false,
|
|
14
|
+
fixura: {
|
|
15
|
+
reader: READERS.JSON,
|
|
16
|
+
failWhenNotFound: false
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
function callback({
|
|
21
|
+
getFixture,
|
|
22
|
+
disabled = false,
|
|
23
|
+
tagPatternRegExp = false,
|
|
24
|
+
expectedError = false,
|
|
25
|
+
useSubsetEquality = false
|
|
26
|
+
}) {
|
|
27
|
+
if (disabled) {
|
|
28
|
+
console.log('TEST DISABLED!'); // eslint-disable-line no-console
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// const base = new MarcRecord(getFixture('base.json'), {subfieldValues: false});
|
|
32
|
+
// const source = new MarcRecord(getFixture('source.json'), {subfieldValues: false});
|
|
33
|
+
|
|
34
|
+
const base = getFixture('base.json');
|
|
35
|
+
const source = getFixture('source.json');
|
|
36
|
+
|
|
37
|
+
const tagPattern = new RegExp(tagPatternRegExp, 'u');
|
|
38
|
+
const expectedRecord = getFixture('merged.json');
|
|
39
|
+
const equalityFunction = useSubsetEquality ? subsetEquality : undefined;
|
|
40
|
+
|
|
41
|
+
// Bypass expected error in testing
|
|
42
|
+
if (expectedError) {
|
|
43
|
+
expect(() => createReducer.to.throw(Error, 'control field'));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const mergedRecord = createReducer({tagPattern, equalityFunction})({base, source});
|
|
48
|
+
expect(mergedRecord).to.eql(expectedRecord);
|
|
49
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"leader": "01331cam a22003494i 4500",
|
|
3
|
+
"fields": [
|
|
4
|
+
{
|
|
5
|
+
"tag": "001",
|
|
6
|
+
"value": "001_base"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"tag": "010",
|
|
10
|
+
"ind1": " ",
|
|
11
|
+
"ind2": " ",
|
|
12
|
+
"subfields": [
|
|
13
|
+
{
|
|
14
|
+
"code": "a",
|
|
15
|
+
"value": "010a_base"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"code": "b",
|
|
19
|
+
"value": "010b_base"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"leader": "01331cam a22003494i 4500",
|
|
3
|
+
"fields": [
|
|
4
|
+
{
|
|
5
|
+
"tag": "001",
|
|
6
|
+
"value": "001_base"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"tag": "010",
|
|
10
|
+
"ind1": " ",
|
|
11
|
+
"ind2": " ",
|
|
12
|
+
"subfields": [
|
|
13
|
+
{
|
|
14
|
+
"code": "a",
|
|
15
|
+
"value": "010a_base"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"code": "b",
|
|
19
|
+
"value": "010b_base"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"leader": "01331cam a22003494i 4500",
|
|
3
|
+
"fields": [
|
|
4
|
+
{
|
|
5
|
+
"tag": "001",
|
|
6
|
+
"value": "001_sorsa"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"tag": "010",
|
|
10
|
+
"ind1": " ",
|
|
11
|
+
"ind2": " ",
|
|
12
|
+
"subfields": [
|
|
13
|
+
{
|
|
14
|
+
"code": "a",
|
|
15
|
+
"value": "010a_sorsa"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"code": "b",
|
|
19
|
+
"value": "010b_sorsa"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"tag": "650",
|
|
25
|
+
"ind1": " ",
|
|
26
|
+
"ind2": "7",
|
|
27
|
+
"subfields": [
|
|
28
|
+
{
|
|
29
|
+
"code": "a",
|
|
30
|
+
"value": "poista mut"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"code": "2",
|
|
34
|
+
"value": "ysa"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
]
|
|
40
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"leader": "01331cam a22003494i 4500",
|
|
3
|
+
"fields": [
|
|
4
|
+
{
|
|
5
|
+
"tag": "001",
|
|
6
|
+
"value": "001_base"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"tag": "010",
|
|
10
|
+
"ind1": " ",
|
|
11
|
+
"ind2": " ",
|
|
12
|
+
"subfields": [
|
|
13
|
+
{
|
|
14
|
+
"code": "a",
|
|
15
|
+
"value": "010a_base"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"code": "b",
|
|
19
|
+
"value": "010b_base"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"leader": "01331cam a22003494i 4500",
|
|
3
|
+
"fields": [
|
|
4
|
+
{
|
|
5
|
+
"tag": "001",
|
|
6
|
+
"value": "001_base"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"tag": "010",
|
|
10
|
+
"ind1": " ",
|
|
11
|
+
"ind2": " ",
|
|
12
|
+
"subfields": [
|
|
13
|
+
{
|
|
14
|
+
"code": "a",
|
|
15
|
+
"value": "010a_base"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"code": "b",
|
|
19
|
+
"value": "010b_base"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|