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,105 +0,0 @@
1
- const test = require('tape');
2
-
3
- const { pkWithDoc } = require('../../lib/load.js');
4
-
5
- const testGroup = 'Hello USFM';
6
-
7
- const pk = pkWithDoc('../test_data/usfm/hello.usfm', {
8
- lang: 'fra',
9
- abbr: 'hello',
10
- })[0];
11
-
12
- test(
13
- `Headers (${testGroup})`,
14
- async function (t) {
15
- try {
16
- const expectedHeaders = [
17
- ['bookCode', 'MRK'],
18
- ['id', 'MRK Mark\'s Gospel, translated by Mark'],
19
- ['toc', 'The Gospel of Mark'],
20
- ['toc2', 'Mark'],
21
- ['toc3', 'Mk'],
22
- ];
23
- t.plan(6 + (2 * expectedHeaders.length));
24
- const query = '{ documents { headers { key value } } }';
25
- const result = await pk.gqlQuery(query);
26
- t.equal(result.errors, undefined);
27
- const queryHeaders = result.data.documents[0].headers;
28
- t.equal(queryHeaders.length, expectedHeaders.length);
29
-
30
- for (const [expectedKey, expectedValue] of expectedHeaders) {
31
- const queryTuple = queryHeaders.filter(kv => kv.key === expectedKey);
32
- t.ok(queryTuple.length === 1);
33
- t.ok(queryTuple[0].value === expectedValue);
34
- }
35
-
36
- const query2 = '{documents { toc: header(id:"toc") toc3: header(id:"toc3") banana: header(id:"banana")} }';
37
- const result2 = await pk.gqlQuery(query2);
38
- t.equal(result2.errors, undefined);
39
- t.equal(result2.data.documents[0].toc, 'The Gospel of Mark');
40
- t.equal(result2.data.documents[0].toc3, 'Mk');
41
- t.equal(result2.data.documents[0].banana, null);
42
- } catch (err) {
43
- console.log(err);
44
- }
45
- },
46
- );
47
- test(
48
- `One-Block Sequence (${testGroup})`,
49
- async function (t) {
50
- try {
51
- t.plan(6);
52
- const query =
53
- '{ documents { sequences { type blocks { bs { payload } text } } } }';
54
- const result = await pk.gqlQuery(query);
55
- t.equal(result.errors, undefined);
56
- const sequences = result.data.documents[0].sequences;
57
- t.equal(sequences.length, 1);
58
- t.equal(sequences[0].type, 'main');
59
- t.equal(sequences[0].blocks.length, 1);
60
- t.equal(sequences[0].blocks[0].bs.payload, 'blockTag/p');
61
- const expectedText = 'This is how the Good News of JC began...';
62
- t.equal(sequences[0].blocks[0].text, expectedText);
63
- } catch (err) {
64
- console.log(err);
65
- }
66
- },
67
- );
68
-
69
- test(
70
- `One Chapter and Verse (${testGroup})`,
71
- async function (t) {
72
- try {
73
- t.plan(6);
74
- const query =
75
- '{ documents { sequences { type blocks { os { payload } is { payload } } } } }';
76
- const result = await pk.gqlQuery(query);
77
- t.equal(result.errors, undefined);
78
- const block = result.data.documents[0].sequences[0].blocks[0];
79
- t.equal(block.os.length, 0);
80
- t.equal(block.is.length, 3);
81
- t.equal(block.is[0].payload, 'chapter/1');
82
- t.equal(block.is[1].payload, 'verse/1');
83
- t.equal(block.is[2].payload, 'verses/1');
84
- } catch (err) {
85
- console.log(err);
86
- }
87
- },
88
- );
89
-
90
- test(
91
- `Query callback (${testGroup})`,
92
- async function (t) {
93
- try {
94
- t.plan(1);
95
- let callbackValue = 2;
96
- const callback = () => callbackValue++;
97
- const query =
98
- '{ nDocuments }';
99
- await pk.gqlQuery(query, callback);
100
- t.equal(callbackValue, 3);
101
- } catch (err) {
102
- console.log(err);
103
- }
104
- },
105
- );
@@ -1,22 +0,0 @@
1
- const test = require('tape');
2
-
3
- const { Proskomma } = require('../../../src/index.cjs');
4
-
5
- const testGroup = 'Document';
6
-
7
- test(
8
- `Unknown Content Format (${testGroup})`,
9
- function (t) {
10
- try {
11
- t.plan(1);
12
- const pk = new Proskomma();
13
-
14
- t.throws(() => pk.importDocument({
15
- lang: 'deu',
16
- abbr: 'xyz',
17
- }, 'mov', 'abc', {}));
18
- } catch (err) {
19
- console.log(err);
20
- }
21
- },
22
- );
@@ -1,48 +0,0 @@
1
- const path = require('path');
2
- const test = require('tape');
3
- const fse = require('fs-extra');
4
- const { Proskomma } = require('../../../src/index.cjs');
5
-
6
- const testGroup = 'importUsfmInt';
7
-
8
- test(
9
- `Import (${testGroup})`,
10
- async function (t) {
11
- try {
12
- t.plan(8);
13
- const pk = new Proskomma();
14
- let fp = '../../test_data/usfm/cp_vp.usfm';
15
- let content = fse.readFileSync(path.resolve(__dirname, fp));
16
-
17
- t.throws(() =>
18
- pk.importUsfmPeriph(
19
- { lang: 'eng', abbr: 'abc' },
20
- content,
21
- {},
22
- ),
23
- /INT.+ESG/);
24
- fp = '../../test_data/usfm/int.usfm';
25
- content = fse.readFileSync(path.resolve(__dirname, fp));
26
-
27
- t.doesNotThrow(() =>
28
- pk.importUsfmPeriph(
29
- { lang: 'eng', abbr: 'abc' },
30
- content,
31
- {},
32
- ));
33
- t.equal(pk.nDocuments(), 2);
34
- const query = '{documents { headers { key value } sequences { type text } } }';
35
- const result = await pk.gqlQuery(query);
36
- t.equal(result.errors, undefined);
37
- const firstDoc = result.data.documents[0];
38
- const headerKeys = firstDoc.headers.map(h => h.key);
39
- t.ok(headerKeys.includes('id'));
40
- t.ok(headerKeys.includes('bookCode'));
41
- t.equal(firstDoc.headers.filter(h => h.key === 'bookCode')[0].value, 'P00');
42
- const introSequence = firstDoc.sequences.filter(s => s.type === 'introduction')[0];
43
- t.equal(introSequence.text, 'The Bible is a book of books.');
44
- } catch (err) {
45
- console.log(err);
46
- }
47
- },
48
- );
@@ -1,133 +0,0 @@
1
- const test = require('tape');
2
-
3
- const { pkWithDoc } = require('../../lib/load.js');
4
-
5
- const testGroup = 'Graph Item Groups';
6
-
7
- const pk = pkWithDoc('../test_data/usfm/verse_breaks_in_blocks.usfm', {
8
- lang: 'eng',
9
- abbr: 'ust',
10
- })[0];
11
- const pk2 = pkWithDoc('../test_data/usfm/ust_psa_with_ts.usfm', {
12
- lang: 'eng',
13
- abbr: 'ust',
14
- })[0];
15
- const pk3 = pkWithDoc('../test_data/usfm/add_test.usfm', {
16
- lang: 'eng',
17
- abbr: 'ust',
18
- })[0];
19
-
20
- test(
21
- `Text by scopes (${testGroup})`,
22
- async function (t) {
23
- try {
24
- t.plan(14);
25
- const query = '{ documents { mainSequence { itemGroups(byScopes:["chapter/", "verse/"]) {' +
26
- 'scopeLabels chapterScope: scopeLabels(startsWith:"chapter/") text dump' +
27
- '} } } }';
28
- let result = await pk.gqlQuery(query);
29
- t.equal(result.errors, undefined);
30
- // console.log(JSON.stringify(result.data.documents[0].mainSequence.itemGroups[1], null, 2))
31
- const itemGroups = result.data.documents[0].mainSequence.itemGroups;
32
- t.equal(itemGroups.length, 3);
33
- t.equal(itemGroups[1].scopeLabels.length, 4);
34
- t.ok(itemGroups[1].scopeLabels.includes('chapter/1'));
35
- t.ok(itemGroups[1].scopeLabels.includes('verse/2'));
36
- t.ok(itemGroups[1].scopeLabels.includes('verses/2'));
37
- t.ok(itemGroups[1].scopeLabels.includes('blockTag/q'));
38
- t.equal(itemGroups[1].chapterScope.length, 1);
39
- t.equal(itemGroups[1].chapterScope[0], 'chapter/1');
40
- t.ok(itemGroups[1].text.startsWith('Instead'));
41
- t.ok(itemGroups[1].text.trim().endsWith('Yahweh teaches.')); // trim cos trailing newline before next \v
42
- const dumped = itemGroups[1].dump.split('\n').map(l => l.trim());
43
- t.ok(dumped[0].startsWith('ItemGroup'));
44
- t.ok(dumped[1].includes('verse/2'));
45
- t.ok(dumped[4].endsWith('-verse/2-'));
46
- } catch (err) {
47
- console.log(err);
48
- }
49
- },
50
- );
51
-
52
- test(
53
- `Text by scopes with multiple hits per block (${testGroup})`,
54
- async function (t) {
55
- try {
56
- t.plan(4);
57
- const query = '{ documents { mainSequence { itemGroups(byScopes:"span/add") {' +
58
- 'scopeLabels(startsWith:["chapter/", "verses/"]) text' +
59
- '} } } }';
60
- let result = await pk3.gqlQuery(query);
61
- t.equal(result.errors, undefined);
62
- t.equal(result.data.documents[0].mainSequence.itemGroups.length, 2);
63
- t.equal(
64
- result.data.documents[0].mainSequence.itemGroups[0].text,
65
- 'Actually, one was Yahweh, and the other two were angels',
66
- );
67
- t.equal(
68
- result.data.documents[0].mainSequence.itemGroups[1].text,
69
- 'to one of them',
70
- );
71
- // console.log(JSON.stringify(result.data.documents[0].mainSequence.itemGroups, null, 2))
72
- } catch (err) {
73
- console.log(err);
74
- }
75
- },
76
- );
77
-
78
- test(
79
- `Items & tokens by scopes (${testGroup})`,
80
- async function (t) {
81
- try {
82
- t.plan(12);
83
- const query = '{ documents { mainSequence { itemGroups(byScopes:["chapter/", "verse/"]) {' +
84
- 'scopeLabels ' +
85
- `items {type subType payload position scopes } ` +
86
- 'tokens { payload }' +
87
- 'wordLikes: tokens(withSubTypes:"wordLike") { payload }' +
88
- '} } } }';
89
- let result = await pk.gqlQuery(query);
90
- t.equal(result.errors, undefined);
91
- const itemGroups = result.data.documents[0].mainSequence.itemGroups;
92
- t.equal(itemGroups.length, 3);
93
- t.equal(itemGroups[1].tokens.length, 57);
94
- t.equal(itemGroups[1].wordLikes.length, 27);
95
- t.equal(itemGroups[1].scopeLabels.length, 4);
96
- t.equal(itemGroups[1].items.filter(i => i.type === 'token')[0].payload, 'Instead');
97
- t.equal(itemGroups[1].items.filter(i => i.type === 'token').reverse()[1].payload, '.'); // Trailing newline before next \v
98
- t.equal(itemGroups[1].tokens[0].payload, 'Instead');
99
- t.equal([...itemGroups[1].tokens].reverse()[1].payload, '.'); // Leading newline (before reversal)
100
- t.equal(itemGroups[0].items.filter(i => i.type === 'graft').length, 1);
101
- t.equal(itemGroups[1].items.filter(i => i.subType === 'start' && i.payload === 'blockTag/q2').length, 0);
102
- t.equal(itemGroups[2].items.filter(i => i.subType === 'start' && i.payload === 'blockTag/q2').length, 1);
103
- } catch (err) {
104
- console.log(err);
105
- }
106
- },
107
- );
108
-
109
- test(
110
- `Text by milestones (${testGroup})`,
111
- async function (t) {
112
- try {
113
- t.plan(9);
114
- const query = '{ documents { mainSequence { itemGroups(byMilestones:["milestone/ts"]) {' +
115
- 'scopeLabels text normalized: text(normalizeSpace:true)' +
116
- '} } } }';
117
- let result = await pk2.gqlQuery(query);
118
- t.equal(result.errors, undefined);
119
- const itemGroups = result.data.documents[0].mainSequence.itemGroups;
120
- t.equal(itemGroups.length, 3);
121
- t.ok(itemGroups[0].scopeLabels.includes('chapter/150'));
122
- t.ok(itemGroups[0].scopeLabels.includes('verse/1'));
123
- t.ok(!itemGroups[1].scopeLabels.includes('verse/1'));
124
- t.ok(itemGroups[1].text.trim().startsWith('Praise'));
125
- t.ok(itemGroups[1].text.trim().endsWith('cymbals!'));
126
- t.equal(itemGroups[0].text.split('\n').length, 5);
127
- t.equal(itemGroups[0].normalized.split('\n').length, 1);
128
- } catch (err) {
129
- console.log(err);
130
- }
131
- },
132
- );
133
-
@@ -1,311 +0,0 @@
1
- const test = require('tape');
2
-
3
- const { pkWithDoc } = require('../../lib/load.js');
4
-
5
- const testGroup = 'Items with 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/usx/web_psa_40_60.usx', {
13
- lang: 'eng',
14
- abbr: 'web',
15
- })[0];
16
-
17
- test(
18
- `Bad cv (${testGroup})`,
19
- async function (t) {
20
- try {
21
- t.plan(2);
22
- const query =
23
- `{ docSets { document(bookCode:"RUT") {
24
- mainSequence { blocks(withScriptureCV:"2") { items(withScriptureCV:"x=y") {type subType payload} } } } }
25
- }`;
26
- const result = await pk.gqlQuery(query);
27
- t.equal(result.errors.length, 1);
28
- t.equal(result.errors.filter(e => e.message.includes('Bad cv reference')).length, 1);
29
- } catch (err) {
30
- console.log(err);
31
- }
32
- },
33
- );
34
-
35
- test(
36
- `withScopes + cv (${testGroup})`,
37
- async function (t) {
38
- try {
39
- t.plan(2);
40
- const query =
41
- `{ docSets { document(bookCode:"RUT") {
42
- mainSequence { blocks(withScriptureCV:"2") { items(withScriptureCV:"2" withScopes:[]) {type, subType, payload} } } } }
43
- }`;
44
- const result = await pk.gqlQuery(query);
45
- t.equal(result.errors.length, 1);
46
- t.equal(result.errors.filter(e => e.message.includes('Cannot specify both withScopes and withScriptureCV')).length, 1);
47
- } catch (err) {
48
- console.log(err);
49
- }
50
- },
51
- );
52
-
53
- test(
54
- `One Chapter (${testGroup})`,
55
- async function (t) {
56
- try {
57
- t.plan(3);
58
- const query =
59
- `{ docSets { document(bookCode:"RUT") {
60
- mainSequence { blocks(withScriptureCV:"2") { items(withScriptureCV:"2") {type, subType, payload} } } } }
61
- }`;
62
- const result = await pk.gqlQuery(query);
63
- t.equal(result.errors, undefined);
64
- const blocks = result.data.docSets[0].document.mainSequence.blocks;
65
- const firstBlockItems = blocks[0].items;
66
- const lastBlockItems = blocks[blocks.length - 1].items;
67
- t.equal(firstBlockItems.filter(i => i.subType === 'wordLike')[0].payload, 'Naomi');
68
- t.equal(lastBlockItems.filter(i => i.subType === 'wordLike').reverse()[0].payload, 'law');
69
- } catch (err) {
70
- console.log(err);
71
- }
72
- },
73
- );
74
-
75
- test(
76
- `Chapter Range (${testGroup})`,
77
- async function (t) {
78
- try {
79
- t.plan(3);
80
- const query =
81
- `{ docSets { document(bookCode:"RUT") {
82
- mainSequence { blocks(withScriptureCV:"1-3") { items(withScriptureCV:"1-3") {type, subType, payload} } } } }
83
- }`;
84
- const result = await pk.gqlQuery(query);
85
- t.equal(result.errors, undefined);
86
- const blocks = result.data.docSets[0].document.mainSequence.blocks;
87
- const firstBlockItems = blocks[0].items;
88
- const lastBlockItems = blocks[blocks.length - 1].items;
89
- t.equal(firstBlockItems.filter(i => i.subType === 'wordLike')[0].payload, 'In');
90
- t.equal(lastBlockItems.filter(i => i.subType === 'wordLike').reverse()[0].payload, 'today');
91
- } catch (err) {
92
- console.log(err);
93
- }
94
- },
95
- );
96
-
97
- test(
98
- `Reverse Chapter Range (${testGroup})`,
99
- async function (t) {
100
- try {
101
- t.plan(2);
102
- const query =
103
- `{ docSets { document(bookCode:"RUT") {
104
- mainSequence { blocks(withScriptureCV:"1-3") { items(withScriptureCV:"3-1") {type, subType, payload} } } } }
105
- }`;
106
- const result = await pk.gqlQuery(query);
107
- t.equal(result.errors.length, 1);
108
- t.equal(result.errors.filter(e => e.message.includes('Chapter range must be from min to max')).length, 1);
109
- } catch (err) {
110
- console.log(err);
111
- }
112
- },
113
- );
114
-
115
- test(
116
- `One verse (${testGroup})`,
117
- async function (t) {
118
- try {
119
- t.plan(3);
120
- const query =
121
- `{ docSets { document(bookCode:"RUT") {
122
- mainSequence { blocks(withScriptureCV:"1:15") { items(withScriptureCV:"1:15") {type, subType, payload} } } } }
123
- }`;
124
- const result = await pk.gqlQuery(query);
125
- t.equal(result.errors, undefined);
126
- const blocks = result.data.docSets[0].document.mainSequence.blocks;
127
- const firstBlockItems = blocks[0].items;
128
- const lastBlockItems = blocks[blocks.length - 1].items;
129
- t.equal(firstBlockItems.filter(i => i.subType === 'wordLike')[0].payload, 'She');
130
- t.equal(lastBlockItems.filter(i => i.subType === 'wordLike').reverse()[0].payload, 'law');
131
- } catch (err) {
132
- console.log(err);
133
- }
134
- },
135
- );
136
-
137
- test(
138
- `Verse zero (${testGroup})`,
139
- async function (t) {
140
- try {
141
- t.plan(3);
142
- const query =
143
- `{ docSets { document(bookCode:"PSA") {
144
- mainSequence { blocks(withScriptureCV:"51:0") { items(withScriptureCV:"51:0") {type, subType, payload} } } } }
145
- }`;
146
- const result = await pk2.gqlQuery(query);
147
- t.equal(result.errors, undefined);
148
- const blocks = result.data.docSets[0].document.mainSequence.blocks;
149
- const firstBlockItems = blocks[0].items;
150
- const lastBlockItems = blocks[blocks.length - 1].items;
151
- t.equal(firstBlockItems.filter(i => i.subType === 'wordLike')[0].payload, 'For');
152
- t.equal(lastBlockItems.filter(i => i.subType === 'wordLike').reverse()[0].payload, 'Bathsheba');
153
- } catch (err) {
154
- console.log(err);
155
- }
156
- },
157
- );
158
-
159
- test(
160
- `Verse range (${testGroup})`,
161
- async function (t) {
162
- try {
163
- t.plan(3);
164
- const query =
165
- `{ docSets { document(bookCode:"RUT") {
166
- mainSequence { blocks(withScriptureCV:"1:10-13") { items(withScriptureCV:"1:10-13") {type, subType, payload} } } } }
167
- }`;
168
- const result = await pk.gqlQuery(query);
169
- t.equal(result.errors, undefined);
170
- const blocks = result.data.docSets[0].document.mainSequence.blocks;
171
- const firstBlockItems = blocks[0].items;
172
- const lastBlockItems = blocks[blocks.length - 1].items;
173
- t.equal(firstBlockItems.filter(i => i.subType === 'wordLike')[0].payload, 'They');
174
- t.equal(lastBlockItems.filter(i => i.subType === 'wordLike').reverse()[0].payload, 'me');
175
- } catch (err) {
176
- console.log(err);
177
- }
178
- },
179
- );
180
-
181
- test(
182
- `Verse range from zero (${testGroup})`,
183
- async function (t) {
184
- try {
185
- t.plan(3);
186
- const query =
187
- `{ docSets { document(bookCode:"PSA") {
188
- mainSequence { blocks(withScriptureCV:"51:0-1") { items(withScriptureCV:"51:0-1") {type, subType, payload} } } } }
189
- }`;
190
- const result = await pk2.gqlQuery(query);
191
- t.equal(result.errors, undefined);
192
- const blocks = result.data.docSets[0].document.mainSequence.blocks;
193
- const firstBlockItems = blocks[0].items;
194
- const lastBlockItems = blocks[blocks.length - 1].items;
195
- t.equal(firstBlockItems.filter(i => i.subType === 'wordLike')[0].payload, 'For');
196
- t.equal(lastBlockItems.filter(i => i.subType === 'wordLike').reverse()[0].payload, 'transgressions');
197
- } catch (err) {
198
- console.log(err);
199
- }
200
- },
201
- );
202
-
203
- test(
204
- `Chapter/verse range (${testGroup})`,
205
- async function (t) {
206
- try {
207
- t.plan(3);
208
- const query =
209
- `{ docSets { document(bookCode:"RUT") {
210
- mainSequence { blocks(withScriptureCV:"1:22-3:3") { items(withScriptureCV:"1:22-3:3") {type, subType, payload} } } } }
211
- }`;
212
- const result = await pk.gqlQuery(query);
213
- t.equal(result.errors, undefined);
214
- const blocks = result.data.docSets[0].document.mainSequence.blocks;
215
- const firstBlockItems = blocks[0].items;
216
- const lastBlockItems = blocks[blocks.length - 1].items;
217
- t.equal(firstBlockItems.filter(i => i.subType === 'wordLike')[0].payload, 'So');
218
- t.equal(lastBlockItems.filter(i => i.subType === 'wordLike').reverse()[0].payload, 'drinking');
219
- } catch (err) {
220
- console.log(err);
221
- }
222
- },
223
- );
224
-
225
- test(
226
- `Chapter/verse range to zero (${testGroup})`,
227
- async function (t) {
228
- try {
229
- t.plan(3);
230
- const query =
231
- `{ docSets { document(bookCode:"PSA") {
232
- mainSequence { blocks(withScriptureCV:"50:23-51:0") { items(withScriptureCV:"50:23-51:0") {type, subType, payload} } } } }
233
- }`;
234
- const result = await pk2.gqlQuery(query);
235
- t.equal(result.errors, undefined);
236
- const blocks = result.data.docSets[0].document.mainSequence.blocks;
237
- const firstBlockItems = blocks[0].items;
238
- const lastBlockItems = blocks[blocks.length - 1].items;
239
- t.equal(firstBlockItems.filter(i => i.subType === 'wordLike')[0].payload, 'Whoever');
240
- t.equal(lastBlockItems.filter(i => i.subType === 'wordLike').reverse()[0].payload, 'Bathsheba');
241
- } catch (err) {
242
- console.log(err);
243
- }
244
- },
245
- );
246
-
247
- test(
248
- `Chapter/verse range from zero (${testGroup})`,
249
- async function (t) {
250
- try {
251
- t.plan(3);
252
- const query =
253
- `{ docSets { document(bookCode:"PSA") {
254
- mainSequence { blocks(withScriptureCV:"51:0-52:1") { items(withScriptureCV:"51:0-52:1") {type, subType, payload} } } } }
255
- }`;
256
- const result = await pk2.gqlQuery(query);
257
- t.equal(result.errors, undefined);
258
- const blocks = result.data.docSets[0].document.mainSequence.blocks;
259
- const firstBlockItems = blocks[0].items;
260
- const lastBlockItems = blocks[blocks.length - 1].items;
261
- t.equal(firstBlockItems.filter(i => i.subType === 'wordLike')[0].payload, 'For');
262
- t.equal(lastBlockItems.filter(i => i.subType === 'wordLike').reverse()[0].payload, 'continually');
263
- } catch (err) {
264
- console.log(err);
265
- }
266
- },
267
- );
268
-
269
- test(
270
- `Chapter/verse range tokens (${testGroup})`,
271
- async function (t) {
272
- try {
273
- t.plan(3);
274
- const query =
275
- `{ docSets { document(bookCode:"RUT") {
276
- mainSequence { blocks(withScriptureCV:"1:22-3:3") { tokens(withScriptureCV:"1:22-3:3") { subType payload } } } } }
277
- }`;
278
- const result = await pk.gqlQuery(query);
279
- t.equal(result.errors, undefined);
280
- const blocks = result.data.docSets[0].document.mainSequence.blocks;
281
- const firstBlockItems = blocks[0].tokens;
282
- const lastBlockItems = blocks[blocks.length - 1].tokens;
283
- t.equal(firstBlockItems[0].payload, 'So');
284
- t.equal(lastBlockItems.filter(i => i.subType === 'wordLike').reverse()[0].payload, 'drinking');
285
- } catch (err) {
286
- console.log(err);
287
- }
288
- },
289
- );
290
-
291
- test(
292
- `Chapter/verse range text (${testGroup})`,
293
- async function (t) {
294
- try {
295
- t.plan(3);
296
- const query =
297
- `{ docSets { document(bookCode:"RUT") {
298
- mainSequence { blocks(withScriptureCV:"1:22-3:3") { text(withScriptureCV:"1:22-3:3") } } } }
299
- }`;
300
- const result = await pk.gqlQuery(query);
301
- t.equal(result.errors, undefined);
302
- const blocks = result.data.docSets[0].document.mainSequence.blocks;
303
- const firstBlockText = blocks[0].text;
304
- const lastBlockText = blocks[blocks.length - 1].text;
305
- t.ok(firstBlockText.startsWith('So'));
306
- t.ok(lastBlockText.endsWith('drinking.'));
307
- } catch (err) {
308
- console.log(err);
309
- }
310
- },
311
- );