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,289 +0,0 @@
1
- const path = require('path');
2
- const test = require('tape');
3
- const fse = require('fs-extra');
4
-
5
- const { Proskomma } = require('../../../src/index.cjs');
6
- const {
7
- customPkWithDoc,
8
- customPkWithDocs,
9
- } = require('../../lib/load.js');
10
-
11
- const testGroup = 'Graph Selectors';
12
-
13
- test(
14
- `selectors for root (${testGroup})`,
15
- async function (t) {
16
- try {
17
- t.plan(9);
18
- const query = '{ selectors { name type regex min max enum } }';
19
- const pk = new Proskomma();
20
- const result = await pk.gqlQuery(query);
21
- t.equal(result.errors, undefined);
22
- t.ok('selectors' in result.data);
23
- const selectors = result.data.selectors;
24
- t.equal(selectors.length, 2);
25
- t.equal(selectors[0].name, 'lang');
26
- t.equal(selectors[0].type, 'string');
27
- t.equal(selectors[0].regex, '[a-z]{3}');
28
- t.equal(selectors[1].name, 'abbr');
29
- t.equal(selectors[1].type, 'string');
30
- t.equal(selectors[1].regex, null);
31
- } catch (err) {
32
- console.log(err);
33
- }
34
- },
35
- );
36
-
37
- test(
38
- `Throw on bad spec (${testGroup})`,
39
- function (t) {
40
- try {
41
- t.plan(15);
42
- let selectors = [];
43
- const customProskomma = class extends Proskomma {
44
- constructor() {
45
- super();
46
- this.selectors = selectors;
47
- this.validateSelectors();
48
- }
49
- };
50
- t.throws(() => new customProskomma(), /No selectors found/);
51
- selectors = [{}];
52
- t.throws(() => new customProskomma(), /Selector.+has no name/);
53
- selectors = [{ name: 'foo' }];
54
- t.throws(() => new customProskomma(), /Selector.+has no type/);
55
- selectors = [{
56
- name: 'foo',
57
- type: 'banana',
58
- }];
59
- t.throws(() => new customProskomma(), /Type for selector/);
60
- selectors = [{
61
- name: 'foo',
62
- type: 'string',
63
- banana: 'split',
64
- }];
65
- t.throws(() => new customProskomma(), /Unexpected key/);
66
- selectors = [{
67
- name: 'foo',
68
- type: 'string',
69
- min: 23,
70
- }];
71
- t.throws(() => new customProskomma(), /should not include 'min'/);
72
- selectors = [{
73
- name: 'foo',
74
- type: 'string',
75
- max: 23,
76
- }];
77
- t.throws(() => new customProskomma(), /should not include 'max'/);
78
- selectors = [{
79
- name: 'foo',
80
- type: 'string',
81
- regex: '[',
82
- }];
83
- t.throws(() => new customProskomma(), /is not valid/);
84
- selectors = [{
85
- name: 'foo',
86
- type: 'string',
87
- enum: ['a', 'b', 23],
88
- }];
89
- t.throws(() => new customProskomma(), /should be strings/);
90
- selectors = [{
91
- name: 'foo',
92
- type: 'integer',
93
- regex: '[a]',
94
- }];
95
- t.throws(() => new customProskomma(), /should not include 'regex'/);
96
- selectors = [{
97
- name: 'foo',
98
- type: 'integer',
99
- min: '23',
100
- }];
101
- t.throws(() => new customProskomma(), /'min' must be a number/);
102
- selectors = [{
103
- name: 'foo',
104
- type: 'integer',
105
- max: '23',
106
- }];
107
- t.throws(() => new customProskomma(), /'max' must be a number/);
108
- selectors = [{
109
- name: 'foo',
110
- type: 'integer',
111
- min: 23,
112
- max: 22,
113
- }];
114
- t.throws(() => new customProskomma(), /'min' cannot be greater than 'max'/);
115
- selectors = [{
116
- name: 'foo',
117
- type: 'integer',
118
- enum: [1, 2, '3'],
119
- }];
120
- t.throws(() => new customProskomma(), /should be numbers/);
121
- selectors = [
122
- {
123
- name: 'foo',
124
- type: 'string',
125
- regex: '.*',
126
- enum: ['a', 'b', 'c'],
127
- },
128
- {
129
- name: 'baa',
130
- type: 'integer',
131
- min: 1,
132
- max: 9,
133
- enum: [2, 4, 6],
134
- },
135
- ];
136
- t.doesNotThrow(() => new customProskomma());
137
- } catch (err) {
138
- console.log(err);
139
- }
140
- },
141
- );
142
-
143
- test(
144
- `Throw on bad selector name and type (${testGroup})`,
145
- function (t) {
146
- try {
147
- t.plan(8);
148
- const customProskomma = class extends Proskomma {
149
- constructor() {
150
- super();
151
- this.selectors = [
152
- {
153
- name: 'foo',
154
- type: 'string',
155
- regex: '[a-z]+',
156
- enum: ['banana', 'mango', 'apple'],
157
- },
158
- {
159
- name: 'baa',
160
- type: 'integer',
161
- min: 1,
162
- max: 9,
163
- enum: [2, 4, 6, 8],
164
- },
165
- ];
166
- this.validateSelectors();
167
- }
168
- };
169
- const pk = new customProskomma();
170
- const content = fse.readFileSync(path.resolve(__dirname, '../../test_data/usx/web_rut.usx'));
171
- let selectors = {};
172
- const importFn = () => pk.importDocument(
173
- selectors,
174
- 'usx',
175
- content,
176
- );
177
- t.throws(importFn, /Expected selector 'foo' not found/);
178
- selectors = { banana: 23 };
179
- t.throws(importFn, /Unexpected selector/);
180
- selectors = {
181
- foo: 23,
182
- baa: 24,
183
- };
184
- t.throws(importFn, /is of type number \(expected string\)/);
185
- selectors = {
186
- foo: 'banana',
187
- baa: 24.5,
188
- };
189
- t.throws(importFn, /is not an integer/);
190
- selectors = {
191
- foo: 'banana',
192
- baa: 7,
193
- };
194
- t.throws(importFn, /is not in enum/);
195
- selectors = {
196
- foo: 'orange',
197
- baa: 8,
198
- };
199
- t.throws(importFn, /is not in enum/);
200
- selectors = {
201
- foo: '123',
202
- baa: 8,
203
- };
204
- t.throws(importFn, /does not match regex/);
205
- selectors = {
206
- foo: 'banana',
207
- baa: 6,
208
- };
209
- t.doesNotThrow(importFn);
210
- } catch (err) {
211
- console.log(err);
212
- }
213
- },
214
- );
215
-
216
- test(
217
- `selectors in graph for docSet (${testGroup})`,
218
- async function (t) {
219
- try {
220
- const customProskomma = class extends Proskomma {
221
- constructor() {
222
- super();
223
- this.selectors = [
224
- {
225
- name: 'foo',
226
- type: 'string',
227
- },
228
- {
229
- name: 'baa',
230
- type: 'integer',
231
- },
232
- ];
233
- this.validateSelectors();
234
- }
235
- };
236
- let cpk = customPkWithDoc(customProskomma, '../test_data/usx/web_rut.usx', {
237
- foo: 'banana',
238
- baa: 23,
239
- })[0];
240
- t.plan(17);
241
- let query = '{ docSets { id selectors { key value } } }';
242
- let result = await cpk.gqlQuery(query);
243
- t.equal(result.errors, undefined);
244
- t.ok('selectors' in result.data.docSets[0]);
245
- const selectors = result.data.docSets[0].selectors;
246
- t.equal(selectors[0].key, 'foo');
247
- t.equal(selectors[0].value, 'banana');
248
- t.equal(selectors[1].key, 'baa');
249
- t.equal(selectors[1].value, '23');
250
- t.equal(result.data.docSets[0].id, 'banana_23');
251
- cpk = customPkWithDocs(customProskomma, [
252
- ['../test_data/usx/web_rut.usx', {
253
- foo: 'banana',
254
- baa: 23,
255
- }],
256
- ['../test_data/usx/web_psa150.usx', {
257
- foo: 'banana',
258
- baa: 48,
259
- }],
260
- ['../test_data/usx/fig.usx', {
261
- foo: 'mango',
262
- baa: 48,
263
- }],
264
- ]);
265
- query = '{ docSets { foo: selector(id:"foo") baa: selector(id:"baa") } }';
266
- result = await cpk.gqlQuery(query);
267
- t.equal(result.errors, undefined);
268
- t.equal(result.data.docSets.length, 3);
269
- query = '{ docSets(withSelectors:[{key:"foo", value:"banana"}]) { foo: selector(id:"foo") baa: selector(id:"baa") } }';
270
- result = await cpk.gqlQuery(query);
271
- t.equal(result.errors, undefined);
272
- t.equal(result.data.docSets.length, 2);
273
- query = '{ docSets(withSelectors:[{key:"baa", value:"48"}]) { foo: selector(id:"foo") baa: selector(id:"baa") } }';
274
- result = await cpk.gqlQuery(query);
275
- t.equal(result.errors, undefined);
276
- t.equal(result.data.docSets.length, 2);
277
- query = '{ docSets(withSelectors:[{key: "foo", value:"banana"}, {key:"baa", value:"48"}]) { foo: selector(id:"foo") baa: selector(id:"baa") } }';
278
- result = await cpk.gqlQuery(query);
279
- t.equal(result.errors, undefined);
280
- t.equal(result.data.docSets.length, 1);
281
- query = '{ docSets(withSelectors:[{key:"foo", value:"durian"}]) { foo: selector(id:"foo") baa: selector(id:"baa") } }';
282
- result = await cpk.gqlQuery(query);
283
- t.equal(result.errors, undefined);
284
- t.equal(result.data.docSets.length, 0);
285
- } catch (err) {
286
- console.log(err);
287
- }
288
- },
289
- );
@@ -1,361 +0,0 @@
1
- const test = require('tape');
2
-
3
- const { pkWithDoc } = require('../../lib/load.js');
4
-
5
- const testGroup = 'Graph Sequence';
6
-
7
- const [pk] = pkWithDoc('../test_data/usfm/hello.usfm', {
8
- lang: 'eng',
9
- abbr: 'ust',
10
- });
11
- const pk2 = pkWithDoc('../test_data/usx/web_rut.usx', {
12
- lang: 'eng',
13
- abbr: 'web',
14
- })[0];
15
-
16
- test(
17
- `Scalars (${testGroup})`,
18
- async function (t) {
19
- try {
20
- t.plan(5);
21
- const query = '{ documents { mainSequence { id type nBlocks } } }';
22
- const result = await pk.gqlQuery(query);
23
- t.equal(result.errors, undefined);
24
- t.ok('mainSequence' in result.data.documents[0]);
25
- t.ok('id' in result.data.documents[0].mainSequence);
26
- t.equal(result.data.documents[0].mainSequence.type, 'main');
27
- t.equal(result.data.documents[0].mainSequence.nBlocks, 1);
28
- } catch (err) {
29
- console.log(err);
30
- }
31
- },
32
- );
33
-
34
- test(
35
- `Blocks (${testGroup})`,
36
- async function (t) {
37
- try {
38
- t.plan(4);
39
- const query = '{ documents { mainSequence { blocks { text } } } }';
40
- const result = await pk.gqlQuery(query);
41
- t.equal(result.errors, undefined);
42
- t.ok('blocks' in result.data.documents[0].mainSequence);
43
- t.ok('text' in result.data.documents[0].mainSequence.blocks[0]);
44
- t.equal(result.data.documents[0].mainSequence.blocks[0].text, 'This is how the Good News of JC began...');
45
- } catch (err) {
46
- console.log(err);
47
- }
48
- },
49
- );
50
-
51
- test(
52
- `position (${testGroup})`,
53
- async function (t) {
54
- try {
55
- t.plan(8);
56
- let query = '{ documents { mainSequence { blocks(positions: [0]) { text } } } }';
57
- let result = await pk2.gqlQuery(query);
58
- t.equal(result.errors, undefined);
59
- t.ok('blocks' in result.data.documents[0].mainSequence);
60
- t.equal(result.data.documents[0].mainSequence.blocks.length, 1);
61
- t.ok(result.data.documents[0].mainSequence.blocks[0].text.startsWith('In the days when the judges judged'));
62
- query = '{ documents { mainSequence { blocks(positions: []) { text } } } }';
63
- result = await pk2.gqlQuery(query);
64
- t.equal(result.errors, undefined);
65
- t.ok('blocks' in result.data.documents[0].mainSequence);
66
- t.equal(result.data.documents[0].mainSequence.blocks.length, 0);
67
- query = '{ documents { mainSequence { blocks(positions: [1, 3, 1]) { text } } } }';
68
- result = await pk2.gqlQuery(query);
69
- t.equal(result.data.documents[0].mainSequence.blocks.length, 2);
70
- } catch (err) {
71
- console.log(err);
72
- }
73
- },
74
- );
75
-
76
- test(
77
- `withScopes (${testGroup})`,
78
- async function (t) {
79
- try {
80
- t.plan(7);
81
- let query = '{ documents { mainSequence { blocks(withScopes:["chapter/1", "verse/1"]) { text } } } }';
82
- let result = await pk.gqlQuery(query);
83
- t.equal(result.errors, undefined);
84
- t.ok('blocks' in result.data.documents[0].mainSequence);
85
- t.equal(result.data.documents[0].mainSequence.blocks.length, 1);
86
- t.equal(result.data.documents[0].mainSequence.blocks[0].text, 'This is how the Good News of JC began...');
87
- query = '{ documents { mainSequence { blocks(withScopes:["chapter/1", "verse/2"]) { text } } } }';
88
- result = await pk.gqlQuery(query);
89
- t.equal(result.errors, undefined);
90
- t.ok('blocks' in result.data.documents[0].mainSequence);
91
- t.equal(result.data.documents[0].mainSequence.blocks.length, 0);
92
- } catch (err) {
93
- console.log(err);
94
- }
95
- },
96
- );
97
-
98
- test(
99
- `withBlockScope (${testGroup})`,
100
- async function (t) {
101
- try {
102
- t.plan(6);
103
- let query = '{ documents { mainSequence { blocks(withBlockScope:"blockTag/p") { text } } } }';
104
- let result = await pk.gqlQuery(query);
105
- t.equal(result.errors, undefined);
106
- t.ok('blocks' in result.data.documents[0].mainSequence);
107
- t.equal(result.data.documents[0].mainSequence.blocks.length, 1);
108
- query = '{ documents { mainSequence { blocks(withBlockScope:"blockTag/q") { text } } } }';
109
- result = await pk.gqlQuery(query);
110
- t.equal(result.errors, undefined);
111
- t.ok('blocks' in result.data.documents[0].mainSequence);
112
- t.equal(result.data.documents[0].mainSequence.blocks.length, 0);
113
- } catch (err) {
114
- console.log(err);
115
- }
116
- },
117
- );
118
-
119
- test(
120
- `withChars 'or' (${testGroup})`,
121
- async function (t) {
122
- try {
123
- t.plan(27);
124
- let query = '{ documents { mainSequence { blocks(withChars:["Boaz" "Naomi"]) { text } } } }';
125
- let result = await pk2.gqlQuery(query);
126
- t.equal(result.errors, undefined);
127
- t.ok('blocks' in result.data.documents[0].mainSequence);
128
- const blocks = result.data.documents[0].mainSequence.blocks;
129
- t.equal(blocks.length, 24);
130
-
131
- for (const block of blocks) {
132
- t.ok(block.text.includes('Boaz') || block.text.includes('Naomi'));
133
- }
134
- } catch (err) {
135
- console.log(err);
136
- }
137
- },
138
- );
139
-
140
- test(
141
- `withChars 'and' (${testGroup})`,
142
- async function (t) {
143
- try {
144
- t.plan(11);
145
- let query = '{ documents { mainSequence { blocks(withChars:["Boaz" "Naomi"] allChars: true) { text } } } }';
146
- let result = await pk2.gqlQuery(query);
147
- t.equal(result.errors, undefined);
148
- t.ok('blocks' in result.data.documents[0].mainSequence);
149
- const blocks = result.data.documents[0].mainSequence.blocks;
150
- t.equal(blocks.length, 8);
151
-
152
- for (const block of blocks) {
153
- t.ok(block.text.includes('Boaz') && block.text.includes('Naomi'));
154
- }
155
- } catch (err) {
156
- console.log(err);
157
- }
158
- },
159
- );
160
-
161
- test(
162
- `withMatchingChars 'or' (${testGroup})`,
163
- async function (t) {
164
- try {
165
- t.plan(3);
166
- let query = '{ documents { mainSequence { blocks(withMatchingChars:["judge", "amminadab"]) { text } } } }';
167
- let result = await pk2.gqlQuery(query);
168
- t.equal(result.errors, undefined);
169
- t.ok('blocks' in result.data.documents[0].mainSequence);
170
- const blocks = result.data.documents[0].mainSequence.blocks;
171
- t.equal(blocks.length, 2);
172
- // console.log(JSON.stringify(blocks, null, 2));
173
- } catch (err) {
174
- console.log(err);
175
- }
176
- },
177
- );
178
-
179
- test(
180
- `withMatchingChars 'and' (${testGroup})`,
181
- async function (t) {
182
- try {
183
- t.plan(3);
184
- let query = '{ documents { mainSequence { blocks(withMatchingChars:["naomi", "ruth", "boaz", "field"] allChars:true) { text } } } }';
185
- let result = await pk2.gqlQuery(query);
186
- t.equal(result.errors, undefined);
187
- t.ok('blocks' in result.data.documents[0].mainSequence);
188
- const blocks = result.data.documents[0].mainSequence.blocks;
189
- t.equal(blocks.length, 3);
190
- // console.log(JSON.stringify(blocks, null, 2));
191
- } catch (err) {
192
- console.log(err);
193
- }
194
- },
195
- );
196
-
197
- test(
198
- `wordLikes (${testGroup})`,
199
- async function (t) {
200
- try {
201
- t.plan(6);
202
- let query = '{ documents { mainSequence { wordLikes } } }';
203
- let result = await pk.gqlQuery(query);
204
- t.equal(result.errors, undefined);
205
- t.ok(result.data.documents[0].mainSequence.wordLikes.includes('Good'));
206
- query = '{ documents { mainSequence { wordLikes(coerceCase:"toLower") } } }';
207
- result = await pk.gqlQuery(query);
208
- t.equal(result.errors, undefined);
209
- t.ok(result.data.documents[0].mainSequence.wordLikes.includes('good'));
210
- query = '{ documents { mainSequence { wordLikes(coerceCase:"toUpper") } } }';
211
- result = await pk.gqlQuery(query);
212
- t.equal(result.errors, undefined);
213
- t.ok(result.data.documents[0].mainSequence.wordLikes.includes('GOOD'));
214
- } catch
215
- (err) {
216
- console.log(err);
217
- }
218
- },
219
- );
220
-
221
- test(
222
- `hasChars (${testGroup})`,
223
- async function (t) {
224
- try {
225
- t.plan(4);
226
- const query = '' +
227
- '{' +
228
- ' documents {' +
229
- ' mainSequence {' +
230
- ' orLogic: hasChars(chars:["Ruth", "Boaz", "banana"])' +
231
- ' andLogic: hasChars(chars:["Ruth", "Boaz", "banana"] allChars:true)' +
232
- ' allMiss: hasChars(chars: ["banana", "grapefruit"])' +
233
- ' }' +
234
- ' }' +
235
- '}';
236
- const result = await pk2.gqlQuery(query);
237
- t.equal(result.errors, undefined);
238
- const sequence = result.data.documents[0].mainSequence;
239
- t.ok(sequence.orLogic);
240
- t.ok(!sequence.andLogic);
241
- t.ok(!sequence.allMiss);
242
- } catch (err) {
243
- console.log(err);
244
- }
245
- },
246
- );
247
-
248
- test(
249
- `hasMatchingChars (${testGroup})`,
250
- async function (t) {
251
- try {
252
- t.plan(3);
253
- const query = '' +
254
- '{' +
255
- ' documents {' +
256
- ' mainSequence {' +
257
- ' orLogic: hasMatchingChars(chars:["Rut", "oaz", "banana"])' +
258
- ' andLogic: hasMatchingChars(chars:["Rut", "oaz", "banana"] allChars:true)' +
259
- ' }' +
260
- ' }' +
261
- '}';
262
- const result = await pk2.gqlQuery(query);
263
- t.equal(result.errors, undefined);
264
- const sequence = result.data.documents[0].mainSequence;
265
- t.ok(sequence.orLogic);
266
- t.ok(!sequence.andLogic);
267
- } catch (err) {
268
- console.log(err);
269
- }
270
- },
271
- );
272
-
273
- test(
274
- `blocksItems (${testGroup})`,
275
- async function (t) {
276
- try {
277
- t.plan(7);
278
- const query = '{ documents { mainSequence { blocksItems { type subType payload } } } }';
279
- const result = await pk2.gqlQuery(query);
280
- t.equal(result.errors, undefined);
281
- t.ok('documents' in result.data);
282
- t.ok('blocksItems' in result.data.documents[0].mainSequence);
283
- const blocksItems = result.data.documents[0].mainSequence.blocksItems;
284
- t.equal(blocksItems[0][0].payload, 'chapter/1');
285
- t.equal(blocksItems[0][1].payload, 'verse/1');
286
- t.equal(blocksItems[0][2].payload, 'verses/1');
287
- t.equal(blocksItems[0][3].payload, 'In');
288
- } catch (err) {
289
- console.log(err);
290
- }
291
- },
292
- );
293
-
294
- test(
295
- `blocksTokens (${testGroup})`,
296
- async function (t) {
297
- try {
298
- t.plan(4);
299
- const query = '{ documents { mainSequence { blocksTokens { type subType payload } } } }';
300
- const result = await pk2.gqlQuery(query);
301
- t.equal(result.errors, undefined);
302
- t.ok('documents' in result.data);
303
- t.ok('blocksTokens' in result.data.documents[0].mainSequence);
304
- t.equal(result.data.documents[0].mainSequence.blocksTokens[0][0].payload, 'In');
305
- } catch (err) {
306
- console.log(err);
307
- }
308
- },
309
- );
310
-
311
- test(
312
- `blocksText (${testGroup})`,
313
- async function (t) {
314
- try {
315
- t.plan(5);
316
- const query = '{ documents { mainSequence { blocksText normalized: blocksText(normalizeSpace:true) } } }';
317
- const result = await pk2.gqlQuery(query);
318
- t.equal(result.errors, undefined);
319
- t.ok('documents' in result.data);
320
- t.ok('blocksText' in result.data.documents[0].mainSequence);
321
- t.ok(result.data.documents[0].mainSequence.blocksText[0].startsWith('In the days when'));
322
- t.ok(result.data.documents[0].mainSequence.normalized[0].startsWith('In the days when'));
323
- } catch (err) {
324
- console.log(err);
325
- }
326
- },
327
- );
328
-
329
- test(
330
- `text (${testGroup})`,
331
- async function (t) {
332
- try {
333
- t.plan(4);
334
- const query = '{ documents { mainSequence { text } } }';
335
- const result = await pk2.gqlQuery(query);
336
- t.equal(result.errors, undefined);
337
- t.ok('documents' in result.data);
338
- t.ok('text' in result.data.documents[0].mainSequence);
339
- t.ok(result.data.documents[0].mainSequence.text.startsWith('In the days when'));
340
- } catch (err) {
341
- console.log(err);
342
- }
343
- },
344
- );
345
-
346
- test(
347
- `text with normalized space (${testGroup})`,
348
- async function (t) {
349
- try {
350
- t.plan(4);
351
- const query = '{ documents { mainSequence { text(normalizeSpace:true) } } }';
352
- const result = await pk2.gqlQuery(query);
353
- t.equal(result.errors, undefined);
354
- t.ok('documents' in result.data);
355
- t.ok('text' in result.data.documents[0].mainSequence);
356
- t.ok(result.data.documents[0].mainSequence.text.startsWith('In the days when'));
357
- } catch (err) {
358
- console.log(err);
359
- }
360
- },
361
- );