proskomma-core 0.9.12 → 0.9.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/esm/wrapper.mjs +1 -1
  2. package/{index.js → index.cjs} +1 -1
  3. package/package.json +2 -2
  4. package/babel.config.js +0 -18
  5. package/test/code/main/bad.cjs +0 -79
  6. package/test/code/main/basics.cjs +0 -534
  7. package/test/code/main/block.cjs +0 -586
  8. package/test/code/main/block_scope_numbers.cjs +0 -31
  9. package/test/code/main/blocks_with_atts.cjs +0 -150
  10. package/test/code/main/blocks_with_cv.cjs +0 -250
  11. package/test/code/main/break.cjs +0 -73
  12. package/test/code/main/checksum.cjs +0 -36
  13. package/test/code/main/cl_global.cjs +0 -35
  14. package/test/code/main/class_for_fragment.cjs +0 -18
  15. package/test/code/main/clean_usfm.cjs +0 -46
  16. package/test/code/main/cp_vp.cjs +0 -158
  17. package/test/code/main/custom.cjs +0 -124
  18. package/test/code/main/cv.cjs +0 -249
  19. package/test/code/main/cvMatching.cjs +0 -155
  20. package/test/code/main/cv_indexes.cjs +0 -189
  21. package/test/code/main/cv_navigation.cjs +0 -124
  22. package/test/code/main/document.cjs +0 -382
  23. package/test/code/main/empty_blocks.cjs +0 -71
  24. package/test/code/main/entries.cjs +0 -402
  25. package/test/code/main/export_lexing_regexes.cjs +0 -19
  26. package/test/code/main/fig.cjs +0 -67
  27. package/test/code/main/filter.cjs +0 -222
  28. package/test/code/main/glossary.cjs +0 -36
  29. package/test/code/main/graft_headings.cjs +0 -36
  30. package/test/code/main/graft_introduction.cjs +0 -96
  31. package/test/code/main/graft_note.cjs +0 -104
  32. package/test/code/main/graft_rems.cjs +0 -34
  33. package/test/code/main/graft_sidebars.cjs +0 -62
  34. package/test/code/main/graft_title.cjs +0 -36
  35. package/test/code/main/hello.cjs +0 -105
  36. package/test/code/main/import_document.cjs +0 -22
  37. package/test/code/main/import_usfm_int.cjs +0 -48
  38. package/test/code/main/item_groups.cjs +0 -133
  39. package/test/code/main/items_with_cv.cjs +0 -311
  40. package/test/code/main/milestone_attributes.cjs +0 -163
  41. package/test/code/main/mixed_sequence_documents.cjs +0 -137
  42. package/test/code/main/mixed_sequences.cjs +0 -217
  43. package/test/code/main/modify_sequence.cjs +0 -29
  44. package/test/code/main/multiple_chapters.cjs +0 -58
  45. package/test/code/main/multiple_content.cjs +0 -105
  46. package/test/code/main/mutate_add.cjs +0 -180
  47. package/test/code/main/mutate_delete.cjs +0 -236
  48. package/test/code/main/mutate_rehash.cjs +0 -68
  49. package/test/code/main/mutate_tags.cjs +0 -90
  50. package/test/code/main/mutate_update.cjs +0 -538
  51. package/test/code/main/selectors.cjs +0 -289
  52. package/test/code/main/sequence.cjs +0 -361
  53. package/test/code/main/serialize.cjs +0 -104
  54. package/test/code/main/spans.cjs +0 -51
  55. package/test/code/main/split_long_tokens.cjs +0 -30
  56. package/test/code/main/standard_vrs.cjs +0 -76
  57. package/test/code/main/subclass.cjs +0 -25
  58. package/test/code/main/table.cjs +0 -119
  59. package/test/code/main/tags.cjs +0 -248
  60. package/test/code/main/token_alignment.cjs +0 -84
  61. package/test/code/main/trees.cjs +0 -211
  62. package/test/code/main/tribos.cjs +0 -865
  63. package/test/code/main/tsv.cjs +0 -385
  64. package/test/code/main/usx_ref.cjs +0 -65
  65. package/test/code/main/verse_mapping.cjs +0 -252
  66. package/test/code/main/verse_range.cjs +0 -31
  67. package/test/code/main/word_likes.cjs +0 -41
  68. package/test/code/utils/byte_array.cjs +0 -271
  69. package/test/code/utils/canons.cjs +0 -20
  70. package/test/code/utils/generate_id.cjs +0 -17
  71. package/test/code/utils/graft_defs.cjs +0 -16
  72. package/test/code/utils/inspect.cjs +0 -130
  73. package/test/code/utils/items.cjs +0 -56
  74. package/test/code/utils/push_succinct.cjs +0 -69
  75. package/test/code/utils/scope_defs.cjs +0 -79
  76. package/test/code/utils/serialize.cjs +0 -28
  77. package/test/code/utils/splice.cjs +0 -67
  78. package/test/code/utils/tags.cjs +0 -69
  79. package/test/code/utils/versification.cjs +0 -249
  80. package/test/lib/load.js +0 -110
  81. package/test/skipped_code/diff.js +0 -53
  82. package/test/test_data/inputBlockSpec/dodson.json +0 -1654
  83. package/test/test_data/inputBlockSpec/kv.json +0 -326
  84. package/test/test_data/inputBlockSpec/mk1.json +0 -1019
  85. package/test/test_data/inputBlockSpec/table.json +0 -170
  86. package/test/test_data/tree/genealogy.json +0 -55
  87. package/test/test_data/tree/jude.json +0 -15965
  88. package/test/test_data/tsv/en_tn_66-JUD.tsv +0 -75
  89. package/test/test_data/tsv/twl_JUD.tsv +0 -144
  90. package/test/test_data/usfm/1pe_webbe.usfm +0 -13
  91. package/test/test_data/usfm/66-JUD-ust.usfm +0 -1089
  92. package/test/test_data/usfm/78-GALspavbl.usfm +0 -10
  93. package/test/test_data/usfm/add_test.usfm +0 -15
  94. package/test/test_data/usfm/backslash.usfm +0 -4
  95. package/test/test_data/usfm/cl.usfm +0 -14
  96. package/test/test_data/usfm/cp_vp.usfm +0 -8
  97. package/test/test_data/usfm/custom.usfm +0 -13
  98. package/test/test_data/usfm/en_ust_oba.usfm +0 -875
  99. package/test/test_data/usfm/en_ust_psa_1.usfm +0 -20
  100. package/test/test_data/usfm/fig.usfm +0 -3
  101. package/test/test_data/usfm/filter.usfm +0 -7
  102. package/test/test_data/usfm/footnote.usfm +0 -11
  103. package/test/test_data/usfm/frt.usfm +0 -4
  104. package/test/test_data/usfm/headings.usfm +0 -7
  105. package/test/test_data/usfm/hello.usfm +0 -8
  106. package/test/test_data/usfm/int.usfm +0 -7
  107. package/test/test_data/usfm/milestone_attributes.usfm +0 -7
  108. package/test/test_data/usfm/milestone_attributes_default.usfm +0 -7
  109. package/test/test_data/usfm/no_break_space.usfm +0 -4
  110. package/test/test_data/usfm/no_mt.usfm +0 -6
  111. package/test/test_data/usfm/rems.usfm +0 -6
  112. package/test/test_data/usfm/section_intros.usfm +0 -26
  113. package/test/test_data/usfm/sidebars.usfm +0 -25
  114. package/test/test_data/usfm/slash_in_att.usfm +0 -6
  115. package/test/test_data/usfm/soft_line_break.usfm +0 -4
  116. package/test/test_data/usfm/spans.usfm +0 -5
  117. package/test/test_data/usfm/split_long_tokens.usfm +0 -6
  118. package/test/test_data/usfm/table.usfm +0 -18
  119. package/test/test_data/usfm/table_at_end.usfm +0 -11
  120. package/test/test_data/usfm/table_in_intro.usfm +0 -22
  121. package/test/test_data/usfm/table_no_end_cells.usfm +0 -18
  122. package/test/test_data/usfm/tit_kitchen_sink.usfm +0 -73
  123. package/test/test_data/usfm/titus_template.usfm +0 -58
  124. package/test/test_data/usfm/ugnt_3jn.usfm +0 -265
  125. package/test/test_data/usfm/ult_3jn.usfm +0 -335
  126. package/test/test_data/usfm/unknown.usfm +0 -5
  127. package/test/test_data/usfm/ust_psa.usfm +0 -29
  128. package/test/test_data/usfm/ust_psa_verse_ranges.usfm +0 -24
  129. package/test/test_data/usfm/ust_psa_with_ts.usfm +0 -29
  130. package/test/test_data/usfm/verse_breaks_in_blocks.usfm +0 -20
  131. package/test/test_data/usfm/verse_range.usfm +0 -7
  132. package/test/test_data/usfm/web_ecc.usfm +0 -391
  133. package/test/test_data/usfm/web_psa51.usfm +0 -71
  134. package/test/test_data/usfm/whitespace.usfm +0 -12
  135. package/test/test_data/usfm/xref.usfm +0 -11
  136. package/test/test_data/usx/bad_element.usx +0 -2
  137. package/test/test_data/usx/cp_vp.usx +0 -12
  138. package/test/test_data/usx/diff1.usx +0 -59
  139. package/test/test_data/usx/diff2.usx +0 -74
  140. package/test/test_data/usx/douay_rheims_ecc.usx +0 -58
  141. package/test/test_data/usx/douay_rheims_psa.usx +0 -5366
  142. package/test/test_data/usx/douay_rheims_psa_40_60.usx +0 -666
  143. package/test/test_data/usx/douay_rheims_rut.usx +0 -26
  144. package/test/test_data/usx/esg3.usx +0 -47
  145. package/test/test_data/usx/fig.usx +0 -6
  146. package/test/test_data/usx/milestone_attributes.usx +0 -11
  147. package/test/test_data/usx/not_nfc18_glo.usx +0 -9
  148. package/test/test_data/usx/not_nfc18_phm.usx +0 -24
  149. package/test/test_data/usx/opt_break.usx +0 -10
  150. package/test/test_data/usx/sidebars.usx +0 -29
  151. package/test/test_data/usx/table.usx +0 -23
  152. package/test/test_data/usx/web_psa.usx +0 -8489
  153. package/test/test_data/usx/web_psa150.usx +0 -33
  154. package/test/test_data/usx/web_psa_40_60.usx +0 -1079
  155. package/test/test_data/usx/web_rut.usx +0 -95
  156. package/test/test_data/usx/web_rut_1.usx +0 -17
  157. package/test/test_data/utils/douay_rheims.vrs +0 -520
  158. package/test/test_data/utils/douay_rheims_PSA.usx +0 -5366
  159. package/test/test_data/utils/serialize_example.json +0 -91
  160. package/test/test_data/utils/truncated_versification.vrs +0 -29
  161. package/test/test_data/utils/web_rut_items.json +0 -2977
  162. package/test/test_data/utils/webbe.vrs +0 -395
  163. package/test/test_data/utils/webbe_PSA.usx +0 -8489
  164. package/test/test_data/vrs/douay_rheims.vrs +0 -520
  165. package/test/test_data/vrs/truncated_versification.vrs +0 -27
  166. package/test/test_data/vrs/webbe.vrs +0 -397
  167. package/webpack.prod.js +0 -50
@@ -1,158 +0,0 @@
1
- const test = require('tape');
2
-
3
- const { pkWithDoc } = require('../../lib/load.js');
4
-
5
- const testGroup = 'Pub Numbers';
6
-
7
- const pk = pkWithDoc('../test_data/usfm/cp_vp.usfm', {
8
- lang: 'fra',
9
- abbr: 'hello',
10
- })[0];
11
- const pk2 = pkWithDoc('../test_data/usx/cp_vp.usx', {
12
- lang: 'fra',
13
- abbr: 'hello',
14
- })[0];
15
-
16
- const pk3 = pkWithDoc('../test_data/usx/esg3.usx', {
17
- lang: 'fra',
18
- abbr: 'nfc18',
19
- })[0];
20
-
21
- test(
22
- `USFM (${testGroup})`,
23
- async function (t) {
24
- try {
25
- const expectedScopes = [
26
- ['s', 'chapter/3'],
27
- ['s', 'pubChapter/B'],
28
- ['s', 'verse/14'],
29
- ['s', 'verses/14'],
30
- ['s', 'pubVerse/1b'],
31
- ['e', 'pubVerse/1b'],
32
- ['e', 'verses/14'],
33
- ['e', 'verse/14'],
34
- ['s', 'verse/15'],
35
- ['s', 'verses/15'],
36
- ['s', 'pubVerse/2b'],
37
- ['e', 'pubVerse/2b'],
38
- ['e', 'verses/15'],
39
- ['e', 'verse/15'],
40
- ['e', 'pubChapter/B'],
41
- ['s', 'pubChapter/3bis'],
42
- ['s', 'pubVerse/1'],
43
- ['e', 'pubVerse/1'],
44
- ['e', 'pubChapter/3bis'],
45
- ['e', 'chapter/3'],
46
- ];
47
- t.plan(1 + (expectedScopes.length * 2));
48
- const query =
49
- '{ documents { mainSequence { blocks { items { type subType payload } } } } }';
50
- const result = await pk.gqlQuery(query);
51
- t.equal(result.errors, undefined);
52
- const scopes = result.data.documents[0].mainSequence.blocks[0].items.filter(i => i.type === 'scope');
53
- let count = 0;
54
-
55
- for (const [sOrE, expectedLabel] of expectedScopes) {
56
- t.equal(scopes[count].subType, sOrE === 's' ? 'start' : 'end');
57
- t.equal(scopes[count].payload, expectedLabel);
58
- count++;
59
- }
60
- } catch (err) {
61
- console.log(err);
62
- }
63
- },
64
- );
65
-
66
- test(
67
- `USX (${testGroup})`,
68
- async function (t) {
69
- try {
70
- const expectedScopes = [
71
- ['s', 'chapter/1'],
72
- ['s', 'pubChapter/A'],
73
- ['s', 'altChapter/(A)'],
74
- ['s', 'verse/1'],
75
- ['s', 'verse/2'],
76
- ['s', 'verses/1-2'],
77
- ['s', 'pubVerse/1-2'],
78
- ['s', 'altVerse/1, 2'],
79
- ['e', 'altVerse/1, 2'],
80
- ['e', 'pubVerse/1-2'],
81
- ['e', 'verses/1-2'],
82
- ['e', 'verse/2'],
83
- ['e', 'verse/1'],
84
- ['s', 'verse/3'],
85
- ['s', 'verses/3'],
86
- ['s', 'altVerse/(3)'],
87
- ['e', 'altVerse/(3)'],
88
- ['e', 'verses/3'],
89
- ['e', 'verse/3'],
90
- ['e', 'altChapter/(A)'],
91
- ['e', 'pubChapter/A'],
92
- ['e', 'chapter/1'],
93
- ];
94
- t.plan(1 + (2 * expectedScopes.length));
95
- const query =
96
- '{ documents { mainSequence { blocks { items { type subType payload } } } } }';
97
- const result = await pk2.gqlQuery(query);
98
- // console.log(JSON.stringify(result.data, null, 2))
99
- t.equal(result.errors, undefined);
100
- const scopes = result.data.documents[0].mainSequence.blocks[0].items.filter(i => i.type === 'scope');
101
- let count = 0;
102
-
103
- for (const [sOrE, expectedLabel] of expectedScopes) {
104
- t.equal(scopes[count].subType, sOrE === 's' ? 'start' : 'end');
105
- t.equal(scopes[count].payload, expectedLabel);
106
- count++;
107
- }
108
- } catch (err) {
109
- console.log(err);
110
- }
111
- },
112
- );
113
-
114
- test(
115
- `ESG USX (${testGroup})`,
116
- async function (t) {
117
- try {
118
- const expectedScopes = [
119
- ['s', 'chapter/3'],
120
- ['s', 'verse/1'],
121
- ['s', 'verses/1'],
122
- ['s', 'pubVerse/1'],
123
- ['e', 'pubVerse/1'],
124
- ['e', 'verses/1'],
125
- ['e', 'verse/1'],
126
- ['s', 'verse/2'],
127
- ['s', 'verses/2'],
128
- ['s', 'pubVerse/2'],
129
- ['e', 'pubVerse/2'],
130
- ['e', 'verses/2'],
131
- ['e', 'verse/2'],
132
- ['s', 'pubChapter/B'],
133
- ['s', 'verse/14'],
134
- ['s', 'verses/14'],
135
- ['s', 'pubVerse/1'],
136
- ['e', 'pubVerse/1'],
137
- ['e', 'verses/14'],
138
- ['e', 'verse/14'],
139
- ['e', 'pubChapter/B'],
140
- ];
141
- t.plan(1 + (2 * expectedScopes.length));
142
- const query =
143
- '{ documents { mainSequence { blocks { items { type subType payload } } } } }';
144
- const result = await pk3.gqlQuery(query);
145
- t.equal(result.errors, undefined);
146
- const scopes = result.data.documents[0].mainSequence.blocks.map(b => b.items.filter(i => i.type === 'scope')).reduce((a, b) => a.concat(b));
147
- let count = 0;
148
-
149
- for (const [sOrE, expectedLabel] of expectedScopes) {
150
- t.equal(scopes[count].subType, sOrE === 's' ? 'start' : 'end');
151
- t.equal(scopes[count].payload, expectedLabel);
152
- count++;
153
- }
154
- } catch (err) {
155
- console.log(err);
156
- }
157
- },
158
- );
@@ -1,124 +0,0 @@
1
- /* eslint-disable require-await */
2
- const test = require('tape');
3
-
4
- const { Proskomma } = require('../../../src/index.cjs');
5
- const {
6
- pkWithDoc,
7
- customPkWithDoc,
8
- } = require('../../lib/load.js');
9
-
10
- const testGroup = 'Custom Tags';
11
-
12
- const pk = pkWithDoc('../test_data/usfm/custom.usfm', {
13
- lang: 'fra',
14
- abbr: 'hello',
15
- })[0];
16
-
17
- const customProskomma = class extends Proskomma {
18
- constructor() {
19
- super();
20
- this.filters = {};
21
- this.customTags = {
22
- heading: ['zh'],
23
- paragraph: ['zp'],
24
- char: ['zc'],
25
- word: ['zw'],
26
- intro: ['zhi', 'zip'],
27
- introHeading: ['zhi'],
28
- };
29
- }
30
- };
31
-
32
- const customPk = customPkWithDoc(customProskomma, '../test_data/usfm/custom.usfm', {
33
- lang: 'fra',
34
- abbr: 'hello',
35
- }, {})[0];
36
-
37
- const query = `{ documents { sequences { id type blocks { scopeLabels bs { payload } bg { subType, payload } items {type subType payload} } } } }`;
38
-
39
- test(
40
- `Unknown Tags (${testGroup})`,
41
- async function (t) {
42
- try {
43
- t.plan(7);
44
- const result = await pk.gqlQuery(query);
45
- t.equal(result.errors, undefined);
46
- const sequences = result.data.documents[0].sequences;
47
- t.equal(sequences.length, 3);
48
- const mainSequence = sequences.filter(s => s.type === 'main')[0];
49
- t.equal(mainSequence.blocks.length, 1);
50
- t.equal(mainSequence.blocks[0].items.filter(i => i.payload === 'Custom').length, 1);
51
- t.equal(mainSequence.blocks[0].items.filter(i => i.subType === 'unknown' && i.payload.startsWith('|')).length, 1);
52
- const introSequence = sequences.filter(s => s.type === 'introduction')[0];
53
- t.equal(introSequence.blocks.length, 1);
54
- t.equal(introSequence.blocks[0].items.filter(i => i.payload === 'Custom').length, 1);
55
- } catch (err) {
56
- console.log(err);
57
- }
58
- },
59
- );
60
-
61
- test(
62
- `Declared Tags (${testGroup})`,
63
- async function (t) {
64
- try {
65
- t.plan(15);
66
- const result = await customPk.gqlQuery(query);
67
- t.equal(result.errors, undefined);
68
- const sequences = result.data.documents[0].sequences;
69
- const mainSequence = sequences.filter(s => s.type === 'main')[0];
70
- t.equal(mainSequence.blocks.length, 2);
71
- t.equal(mainSequence.blocks[0].items.filter(i => i.payload === 'Custom').length, 0);
72
- t.equal(mainSequence.blocks[1].items.filter(i => i.payload === 'Custom').length, 0);
73
- t.equal(mainSequence.blocks[1].items.filter(i => i.subType === 'unknown').length, 0);
74
- t.equal(mainSequence.blocks[0].bs.payload, 'blockTag/p');
75
- t.equal(mainSequence.blocks[1].bs.payload, 'blockTag/zp');
76
-
77
- for (const label of ['span/zc', 'spanWithAtts/zw', 'attribute/spanWithAtts/zw/x-foo/0/baa']) {
78
- t.ok(mainSequence.blocks[1].scopeLabels.includes(label));
79
- }
80
-
81
- const introSequence = sequences.filter(s => s.type === 'introduction')[0];
82
- t.equal(introSequence.blocks.length, 2);
83
- t.equal(introSequence.blocks[0].bs.payload, 'blockTag/ip');
84
- t.equal(introSequence.blocks[1].bs.payload, 'blockTag/zip');
85
- t.equal(sequences.filter(s => s.type === 'heading' && s.blocks[0].bs.payload === 'blockTag/zh').length, 1);
86
- t.equal(sequences.filter(s => s.type === 'heading' && s.blocks[0].bs.payload === 'blockTag/zhi').length, 1);
87
- } catch (err) {
88
- console.log(err);
89
- }
90
- },
91
- );
92
-
93
- test(
94
- 'Specify Selector Spec (${testGroup})',
95
- async function (t) {
96
- try {
97
- t.plan(2);
98
- t.doesNotThrow(() => new Proskomma([
99
- {
100
- name: 'lang',
101
- type: 'string',
102
- regex: '[a-z]{3}',
103
- },
104
- {
105
- name: 'abbr',
106
- type: 'string',
107
- },
108
- ]));
109
- t.throws(() => new Proskomma([
110
- {
111
- name: 'lang',
112
- type: 'stringz',
113
- regex: '[a-z]{3}',
114
- },
115
- {
116
- name: 'abbr',
117
- type: 'string',
118
- },
119
- ]), /stringz/);
120
- } catch (err) {
121
- console.log(err);
122
- }
123
- },
124
- );
@@ -1,249 +0,0 @@
1
- const test = require('tape');
2
-
3
- const { pkWithDoc } = require('../../lib/load.js');
4
-
5
- const testGroup = 'CV';
6
-
7
- const pk = pkWithDoc('../test_data/usx/web_rut.usx', {
8
- lang: 'eng',
9
- abbr: 'web',
10
- })[0];
11
-
12
- const pk2 = pkWithDoc('../test_data/usfm/web_psa51.usfm', {
13
- lang: 'eng',
14
- abbr: 'web',
15
- })[0];
16
-
17
- const chapterQuery = `cv (chapter:"3") { scopeLabels, items { type subType payload } tokens { subType payload } text }`;
18
- const chapterVersesChapterQuery = `cv (chapterVerses:"3") { scopeLabels, items { type subType payload } tokens { subType payload } text }`;
19
- const verseQuery = `cv (chapter:"3" verses:["6"]) { scopeLabels, items { type subType payload } tokens { subType payload } text }`;
20
- const versesQuery = `cv (chapter:"3" verses:["6", "7"]) { scopeLabels, items { type subType payload } tokens { subType payload } text }`;
21
- const chapterVersesQuery = `cv (chapterVerses:"3:18-4:1" includeContext:true ) { scopeLabels items { type subType payload position } tokens { subType payload position } text }`;
22
- const repeatChapterVersesQuery = `cv (chapterVerses:"3:16-3:18" includeContext:true ) { scopeLabels items { type subType payload position } tokens { subType payload position } text }`;
23
- const singleChapterVersesQuery = `cv (chapterVerses:"3:16-18" includeContext:true ) { scopeLabels items { type subType payload position } tokens { subType payload position } text }`;
24
- const singleVerseChapterVersesQuery = `cv (chapterVerses:"3:16" includeContext:true ) { scopeLabels items { type subType payload position } tokens { subType payload position } text }`;
25
- const multiParaSingleVerseChapterVersesQuery = `cv (chapterVerses:"51:1") { text }`;
26
-
27
- test(
28
- `Chapter (${testGroup})`,
29
- async function (t) {
30
- try {
31
- t.plan(10);
32
- const query = `{ documents { ${chapterQuery} } }`;
33
- const result = await pk.gqlQuery(query);
34
- t.equal(result.errors, undefined);
35
- const cv = result.data.documents[0].cv;
36
- t.ok(cv[0].scopeLabels.includes('chapter/3'));
37
- t.equal(cv[0].items[0].payload, 'blockTag/p');
38
- t.equal(cv[0].items[1].payload, 'chapter/3');
39
- t.equal([...cv[0].items].reverse()[0].payload, 'blockTag/p');
40
- t.equal([...cv[0].items].reverse()[1].payload, 'chapter/3');
41
- t.equal(cv[0].tokens[0].payload, 'Naomi');
42
- t.equal([...cv[0].tokens].reverse()[2].payload, 'today');
43
- t.ok(cv[0].text.startsWith('Naomi her mother-in-law'));
44
- t.ok(cv[0].text.endsWith('settled this today.”'));
45
- } catch (err) {
46
- console.log(err);
47
- }
48
- },
49
- );
50
-
51
- test(
52
- `Verse (${testGroup})`,
53
- async function (t) {
54
- try {
55
- t.plan(13);
56
- const query = `{ documents { ${verseQuery} } }`;
57
- const result = await pk.gqlQuery(query);
58
- t.equal(result.errors, undefined);
59
- const cv = result.data.documents[0].cv;
60
- t.ok(cv[0].scopeLabels.includes('chapter/3'));
61
- t.ok(cv[0].scopeLabels.includes('verse/6'));
62
- t.equal(cv[0].items[0].payload, 'blockTag/p');
63
- t.equal(cv[0].items[1].payload, 'verse/6');
64
- t.equal(cv[0].items[2].payload, 'verses/6');
65
- t.equal([...cv[0].items].reverse()[0].payload, 'blockTag/p');
66
- t.equal([...cv[0].items].reverse()[1].payload, 'verse/6');
67
- t.equal([...cv[0].items].reverse()[2].payload, 'verses/6');
68
- const wordTokens = cv[0].tokens.filter(t => t.subType === 'wordLike');
69
- t.equal(wordTokens[0].payload, 'She');
70
- t.equal([...wordTokens].reverse()[0].payload, 'her');
71
- t.ok(cv[0].text.startsWith('She went down'));
72
- t.ok(cv[0].text.endsWith('told her. '));
73
- } catch (err) {
74
- console.log(err);
75
- }
76
- },
77
- );
78
-
79
- test(
80
- `Multi-Para Verse (${testGroup})`,
81
- async function (t) {
82
- try {
83
- t.plan(4);
84
- const query = `{ documents { ${multiParaSingleVerseChapterVersesQuery} } }`;
85
- const result = await pk2.gqlQuery(query);
86
- t.equal(result.errors, undefined);
87
- const cv = result.data.documents[0].cv;
88
- t.ok(cv[0].text.startsWith('Have mercy'));
89
- t.ok(cv[0].text.endsWith('transgressions.'));
90
- t.ok(cv[0].text.includes('kindness. According'));
91
- } catch (err) {
92
- console.log(err);
93
- }
94
- },
95
- );
96
-
97
- test(
98
- `Verses (${testGroup})`,
99
- async function (t) {
100
- try {
101
- t.plan(14);
102
- const query = `{ documents { ${versesQuery} } }`;
103
- const result = await pk.gqlQuery(query);
104
- t.equal(result.errors, undefined);
105
- const cv = result.data.documents[0].cv;
106
- t.ok(cv[0].scopeLabels.includes('chapter/3'));
107
- t.ok(cv[0].scopeLabels.includes('verse/6'));
108
- t.ok(cv[1].scopeLabels.includes('verse/7'));
109
- t.equal(cv[0].items[0].payload, 'blockTag/p');
110
- t.equal(cv[0].items[1].payload, 'verse/6');
111
- t.equal(cv[0].items[2].payload, 'verses/6');
112
- t.equal([...cv[1].items].reverse()[0].payload, 'blockTag/p');
113
- t.equal([...cv[1].items].reverse()[1].payload, 'verse/7');
114
- t.equal([...cv[1].items].reverse()[2].payload, 'verses/7');
115
- let wordTokens = cv[0].tokens.filter(t => t.subType === 'wordLike');
116
- wordTokens = wordTokens.concat(cv[1].tokens.filter(t => t.subType === 'wordLike'));
117
- t.equal(wordTokens[0].payload, 'She');
118
- t.equal([...wordTokens].reverse()[0].payload, 'down');
119
- t.ok(cv[0].text.startsWith('She went down'));
120
- t.ok(cv[1].text.endsWith('and lay down. '));
121
- } catch (err) {
122
- console.log(err);
123
- }
124
- },
125
- );
126
-
127
- test(
128
- `ChapterVerses (${testGroup})`,
129
- async function (t) {
130
- try {
131
- t.plan(12);
132
- const query = `{ documents { ${chapterVersesQuery} } }`;
133
- const result = await pk.gqlQuery(query);
134
- t.equal(result.errors, undefined);
135
- const cv = result.data.documents[0].cv;
136
- t.equal(cv.length, 2);
137
- t.equal(cv[0].tokens[0].payload, 'Then');
138
- t.equal([...cv[0].tokens].reverse()[0].payload, '”');
139
- t.ok(cv[0].scopeLabels.includes('chapter/3'));
140
- t.ok(cv[0].scopeLabels.includes('verse/18'));
141
- t.ok(cv[0].scopeLabels.includes('verses/18'));
142
- t.ok(cv[1].scopeLabels.includes('chapter/4'));
143
- t.ok(cv[1].scopeLabels.includes('verse/1'));
144
- t.ok(cv[1].scopeLabels.includes('verses/1'));
145
- t.ok(cv[0].text.startsWith('Then she said'));
146
- t.ok(cv[1].text.endsWith('and sat down. '));
147
- } catch (err) {
148
- console.log(err);
149
- }
150
- },
151
- );
152
-
153
- test(
154
- `Repeat-chapter chapterVerses (${testGroup})`,
155
- async function (t) {
156
- try {
157
- t.plan(12);
158
- const query = `{ documents { ${repeatChapterVersesQuery} } }`;
159
- const result = await pk.gqlQuery(query);
160
- t.equal(result.errors, undefined);
161
- const cv = result.data.documents[0].cv;
162
- t.equal(cv.length, 3);
163
- const wordLikes = cv[0].tokens.filter(t => t.subType === 'wordLike');
164
- t.equal(wordLikes[0].payload, 'When');
165
- t.equal([...wordLikes].reverse()[0].payload, 'her');
166
- t.ok(cv[0].scopeLabels.includes('chapter/3'));
167
- t.ok(cv[0].scopeLabels.includes('verse/16'));
168
- t.ok(cv[0].scopeLabels.includes('verses/16'));
169
- t.ok(cv[2].scopeLabels.includes('chapter/3'));
170
- t.ok(cv[2].scopeLabels.includes('verse/18'));
171
- t.ok(cv[2].scopeLabels.includes('verses/18'));
172
- t.ok(cv[0].text.startsWith('When she came'));
173
- t.ok(cv[2].text.endsWith('settled this today.”'));
174
- } catch (err) {
175
- console.log(err);
176
- }
177
- },
178
- );
179
-
180
- test(
181
- `Single-chapter chapterVerses (${testGroup})`,
182
- async function (t) {
183
- try {
184
- t.plan(12);
185
- const query = `{ documents { ${singleChapterVersesQuery} } }`;
186
- const result = await pk.gqlQuery(query);
187
- t.equal(result.errors, undefined);
188
- const cv = result.data.documents[0].cv;
189
- t.equal(cv.length, 3);
190
- const wordLikes = cv[0].tokens.filter(t => t.subType === 'wordLike');
191
- t.equal(wordLikes[0].payload, 'When');
192
- t.equal([...wordLikes].reverse()[0].payload, 'her');
193
- t.ok(cv[0].scopeLabels.includes('chapter/3'));
194
- t.ok(cv[0].scopeLabels.includes('verse/16'));
195
- t.ok(cv[0].scopeLabels.includes('verses/16'));
196
- t.ok(cv[2].scopeLabels.includes('chapter/3'));
197
- t.ok(cv[2].scopeLabels.includes('verse/18'));
198
- t.ok(cv[2].scopeLabels.includes('verses/18'));
199
- t.ok(cv[0].text.startsWith('When she came'));
200
- t.ok(cv[2].text.endsWith('settled this today.”'));
201
- } catch (err) {
202
- console.log(err);
203
- }
204
- },
205
- );
206
-
207
- test(
208
- `Single-verse chapterVerses (${testGroup})`,
209
- async function (t) {
210
- try {
211
- t.plan(9);
212
- const query = `{ documents { ${singleVerseChapterVersesQuery} } }`;
213
- const result = await pk.gqlQuery(query);
214
- t.equal(result.errors, undefined);
215
- const cv = result.data.documents[0].cv;
216
- t.equal(cv.length, 1);
217
- const wordLikes = cv[0].tokens.filter(t => t.subType === 'wordLike');
218
- t.equal(wordLikes[0].payload, 'When');
219
- t.equal([...wordLikes].reverse()[0].payload, 'her');
220
- t.ok(cv[0].scopeLabels.includes('chapter/3'));
221
- t.ok(cv[0].scopeLabels.includes('verse/16'));
222
- t.ok(cv[0].scopeLabels.includes('verses/16'));
223
- t.ok(cv[0].text.startsWith('When she came'));
224
- t.ok(cv[0].text.endsWith('done for her. '));
225
- } catch (err) {
226
- console.log(err);
227
- }
228
- },
229
- );
230
-
231
- test(
232
- `ChapterVersesVerse (${testGroup})`,
233
- async function (t) {
234
- try {
235
- t.plan(6);
236
- const query = `{ documents { ${chapterVersesChapterQuery} } }`;
237
- const result = await pk.gqlQuery(query);
238
- t.equal(result.errors, undefined);
239
- const cv = result.data.documents[0].cv;
240
- t.equal(cv.length, 18);
241
- t.ok(cv[0].scopeLabels.includes('chapter/3'));
242
- t.ok(cv[0].scopeLabels.includes('verse/1'));
243
- t.ok(cv[17].scopeLabels.includes('chapter/3'));
244
- t.ok(cv[17].scopeLabels.includes('verse/18'));
245
- } catch (err) {
246
- console.log(err);
247
- }
248
- },
249
- );
@@ -1,155 +0,0 @@
1
- const test = require('tape');
2
- const xre = require('xregexp');
3
-
4
- const { pkWithDoc } = require('../../lib/load.js');
5
-
6
- const testGroup = 'cvMatching';
7
-
8
- const pk = pkWithDoc('../test_data/usx/web_rut.usx', {
9
- lang: 'eng',
10
- abbr: 'web',
11
- })[0];
12
-
13
- const pk2 = pkWithDoc('../test_data/usfm/web_psa51.usfm', {
14
- lang: 'eng',
15
- abbr: 'web',
16
- })[0];
17
-
18
- test(
19
- `Error on no filters (${testGroup})`,
20
- async function (t) {
21
- try {
22
- t.plan(2);
23
- const query = '{ documents { cvMatching { scopeLabels text } } }';
24
- const result = await pk.gqlQuery(query);
25
- t.equal(result.errors.length, 1);
26
- t.ok(xre.test(result.errors[0].message, /Must specify at least one/));
27
- } catch (err) {
28
- console.log(err);
29
- }
30
- },
31
- );
32
-
33
- test(
34
- `Error on conflicting filters (${testGroup})`,
35
- async function (t) {
36
- try {
37
- t.plan(2);
38
- const query = '{ documents { cvMatching(withChars:"foo", withMatchingChars:"baa") { scopeLabels text } } }';
39
- const result = await pk.gqlQuery(query);
40
- t.equal(result.errors.length, 1);
41
- t.ok(xre.test(result.errors[0].message, /Must not specify both/));
42
- } catch (err) {
43
- console.log(err);
44
- }
45
- },
46
- );
47
-
48
- test(
49
- `either of 2 exact (${testGroup})`,
50
- async function (t) {
51
- try {
52
- t.plan(2);
53
- const query = '{ documents { cvMatching(withChars:["Ruth", "Boaz"]) { scopeLabels text } } }';
54
- const result = await pk.gqlQuery(query);
55
- t.equal(result.errors, undefined);
56
- t.equal(result.data.documents[0].cvMatching.length, 28);
57
- } catch (err) {
58
- console.log(err);
59
- }
60
- },
61
- );
62
-
63
- test(
64
- `both of 2 exact (${testGroup})`,
65
- async function (t) {
66
- try {
67
- t.plan(2);
68
- const query = '{ documents { cvMatching(withChars:["Ruth", "Boaz"], allChars:true) { scopeLabels text } } }';
69
- const result = await pk.gqlQuery(query);
70
- t.equal(result.errors, undefined);
71
- t.equal(result.data.documents[0].cvMatching.length, 3);
72
- } catch (err) {
73
- console.log(err);
74
- }
75
- },
76
- );
77
-
78
- test(
79
- `either of 2 matching (${testGroup})`,
80
- async function (t) {
81
- try {
82
- t.plan(2);
83
- const query = '{ documents { cvMatching(withMatchingChars:["Ruth", "Moab"]) { scopeLabels text } } }';
84
- const result = await pk.gqlQuery(query);
85
- t.equal(result.errors, undefined);
86
- t.equal(result.data.documents[0].cvMatching.length, 17);
87
- } catch (err) {
88
- console.log(err);
89
- }
90
- },
91
- );
92
-
93
- test(
94
- `both of 2 matching (${testGroup})`,
95
- async function (t) {
96
- try {
97
- t.plan(2);
98
- const query = '{ documents { cvMatching(withMatchingChars:["Ruth", "Moab"], allChars:true) { scopeLabels text } } }';
99
- const result = await pk.gqlQuery(query);
100
- t.equal(result.errors, undefined);
101
- t.equal(result.data.documents[0].cvMatching.length, 6);
102
- } catch (err) {
103
- console.log(err);
104
- }
105
- },
106
- );
107
-
108
- test(
109
- `one scope (${testGroup})`,
110
- async function (t) {
111
- try {
112
- t.plan(3);
113
- const query = '{ documents { cvMatching(withScopes:"attribute/spanWithAtts/w/strong/0/H517") { scopeLabels text } } }';
114
- const result = await pk2.gqlQuery(query);
115
- t.equal(result.errors, undefined);
116
- t.equal(result.data.documents[0].cvMatching.length, 1);
117
- t.ok(result.data.documents[0].cvMatching[0].text.includes('Purify'));
118
- } catch (err) {
119
- console.log(err);
120
- }
121
- },
122
- );
123
-
124
- test(
125
- `either of 2 scopes (${testGroup})`,
126
- async function (t) {
127
- try {
128
- t.plan(4);
129
- const query = '{ documents { cvMatching(withScopes:["attribute/spanWithAtts/w/strong/0/H517", "attribute/spanWithAtts/w/strong/0/H2398"]) { scopeLabels text } } }';
130
- const result = await pk2.gqlQuery(query);
131
- t.equal(result.errors, undefined);
132
- t.equal(result.data.documents[0].cvMatching.length, 2);
133
- t.ok(result.data.documents[0].cvMatching[0].text.includes('Purify'));
134
- t.ok(result.data.documents[0].cvMatching[1].text.includes('Hide'));
135
- } catch (err) {
136
- console.log(err);
137
- }
138
- },
139
- );
140
-
141
- test(
142
- `both of 2 scopes (${testGroup})`,
143
- async function (t) {
144
- try {
145
- t.plan(3);
146
- const query = '{ documents { cvMatching(withScopes:["attribute/spanWithAtts/w/strong/0/H3526", "attribute/spanWithAtts/w/strong/0/H2398"] allScopes:true) { scopeLabels text } } }';
147
- const result = await pk2.gqlQuery(query);
148
- t.equal(result.errors, undefined);
149
- t.equal(result.data.documents[0].cvMatching.length, 1);
150
- t.ok(result.data.documents[0].cvMatching[0].text.includes('Hide'));
151
- } catch (err) {
152
- console.log(err);
153
- }
154
- },
155
- );