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,385 +0,0 @@
1
- const path = require('path');
2
- const fse = require('fs-extra');
3
- const test = require('tape');
4
-
5
- const { Validator } = require('proskomma-json-tools');
6
- const { Proskomma } = require('../../../src/index.cjs');
7
-
8
- const { pkWithDoc } = require('../../lib/load.js');
9
- const {
10
- tsvToInputBlock,
11
- blocksSpec2Query,
12
- } = require('../../../src/util/scriptlike/blocksSpec.cjs');
13
-
14
- const [pk, pkDoc] = pkWithDoc('../test_data/usfm/66-JUD-ust.usfm', {
15
- lang: 'eng',
16
- abbr: 'ust',
17
- });
18
-
19
- const importTable = pk => {
20
- pk.importDocument({
21
- lang: 'deu',
22
- abbr: 'xyz',
23
- }, 'tsv',
24
- JSON.stringify(
25
- {
26
- headings: ['firstCol', 'secondCol'],
27
- rows: [
28
- ['ab.c', 'c ba'],
29
- ['de.f', 'f ed'],
30
- ['gh.i', 'i hg'],
31
- ],
32
- },
33
- ),
34
- {},
35
- );
36
- };
37
-
38
- const tsvToTable = (tsv, hasHeadings) => {
39
- const ret = {
40
- headings: [],
41
- rows: [],
42
- };
43
- let rows = tsv.split(/[\n\r]+/);
44
-
45
- if (hasHeadings) {
46
- ret.headings = rows[0].split('\t');
47
- rows = rows.slice(1);
48
- }
49
-
50
- for (const row of rows) {
51
- ret.rows.push(row.split('\t'));
52
- }
53
- return ret;
54
- };
55
-
56
- const importTSV = (pk, tsvPath, hasHeadings) => {
57
- pk.importDocument({
58
- lang: 'deu',
59
- abbr: 'xyz',
60
- }, 'tsv',
61
- JSON.stringify(
62
- tsvToTable(
63
- fse.readFileSync(
64
- path.resolve(__dirname, tsvPath),
65
- )
66
- .toString(),
67
- hasHeadings,
68
- ),
69
- {},
70
- ),
71
- null,
72
- 2,
73
- );
74
- };
75
-
76
- const testGroup = 'TSV';
77
-
78
- test(
79
- `Return error for tableSequence on non-table sequence (${testGroup})`,
80
- async function (t) {
81
- try {
82
- t.plan(3);
83
- let query = '{documents { id mainSequence { id } } }';
84
- let result = await pk.gqlQuery(query);
85
- t.equal(result.errors, undefined);
86
- const docId = result.data.documents[0].id;
87
- const seqId = result.data.documents[0].mainSequence.id;
88
- query = `{document(id:"${docId}") { tableSequence(id:"${seqId}") { id } } }`;
89
- result = await pk.gqlQuery(query);
90
- t.equal(result.errors.length, 1);
91
- t.ok(result.errors[0].message.includes('type \'table\', not \'main\''));
92
- } catch (err) {
93
- console.log(err);
94
- }
95
- },
96
- );
97
-
98
- test(
99
- `Import nested arrays (${testGroup})`,
100
- async function (t) {
101
- try {
102
- t.plan(7);
103
- const pk = new Proskomma();
104
- importTable(pk);
105
- let query = '{documents { mainSequence { id } sequences { id type tags blocks { bs { payload} bg { payload } is { payload } tokens { type subType payload } } } } }';
106
- let result = await pk.gqlQuery(query);
107
- t.equal(result.errors, undefined);
108
- const doc = result.data.documents[0];
109
- const mainSequence = doc.sequences.filter(s => s.id === doc.mainSequence.id)[0];
110
- const tableGraft = mainSequence.blocks[0].bg[0].payload;
111
- const tableSequence = doc.sequences.filter(s => s.id === tableGraft)[0];
112
- t.equal(tableSequence.type, 'table');
113
- t.equal(tableSequence.tags.length, 2);
114
- t.equal(tableSequence.tags[0], 'col0:firstCol');
115
- t.equal(tableSequence.blocks.length, 6);
116
- t.equal(tableSequence.blocks.filter(b => b.bs.payload === 'tTableRow/1').length, 2);
117
- t.equal(tableSequence.blocks.filter(b => b.is.map(s => s.payload).includes('tTableCol/1')).length, 3);
118
- } catch (err) {
119
- console.log(err);
120
- }
121
- },
122
- );
123
-
124
- test(
125
- `Query Cells (${testGroup})`,
126
- async function (t) {
127
- try {
128
- t.plan(16);
129
- const pk = new Proskomma();
130
- importTable(pk);
131
- let query = '{docSets { document(bookCode:"T00") { sequences(types:"table") { id } } } }';
132
- let result = await pk.gqlQuery(query);
133
- t.equal(result.errors, undefined);
134
- const tableSequenceId = result.data.docSets[0].document.sequences[0].id;
135
- query = `{docSets { document(bookCode:"T00") { tableSequence(id:"${tableSequenceId}") { nCells nRows nColumns cells { rows columns items { payload } tokens { payload } text } } } } }`;
136
- result = await pk.gqlQuery(query);
137
- t.equal(result.errors, undefined);
138
- const sequence = result.data.docSets[0].document.tableSequence;
139
- t.equal(sequence.nCells, 6);
140
- t.equal(sequence.nRows, 3);
141
- t.equal(sequence.nColumns, 2);
142
- t.equal(sequence.cells.length, 6);
143
- const firstCell = sequence.cells[0];
144
- t.equal(firstCell.rows[0], 0);
145
- t.equal(firstCell.columns[0], 0);
146
- t.equal(firstCell.items[1].payload, 'ab');
147
- t.equal(firstCell.tokens[0].payload, 'ab');
148
- t.equal(firstCell.text, 'ab.c');
149
- const lastCell = sequence.cells[5];
150
- t.equal(lastCell.rows[0], 2);
151
- t.equal(lastCell.columns[0], 1);
152
- t.equal(lastCell.items[3].payload, 'hg');
153
- t.equal(lastCell.tokens[2].payload, 'hg');
154
- t.equal(lastCell.text, 'i hg');
155
- } catch (err) {
156
- console.log(err);
157
- }
158
- },
159
- );
160
-
161
- test(
162
- `Query Rows (${testGroup})`,
163
- async function (t) {
164
- try {
165
- t.plan(9);
166
- const pk = new Proskomma();
167
- importTable(pk);
168
- let query = '{docSets { document(bookCode:"T00") { sequences(types:"table") { id } } } }';
169
- let result = await pk.gqlQuery(query);
170
- t.equal(result.errors, undefined);
171
- const tableSequenceId = result.data.docSets[0].document.sequences[0].id;
172
- query = `{docSets { document(bookCode:"T00") { tableSequence(id:"${tableSequenceId}") { rows { columns text } } } } }`;
173
- result = await pk.gqlQuery(query);
174
- t.equal(result.errors, undefined);
175
- const sequenceRows = result.data.docSets[0].document.tableSequence.rows;
176
- t.equal(sequenceRows.length, 3);
177
- t.equal(sequenceRows[0].length, 2);
178
- t.equal(sequenceRows[0][1].columns[0], 1);
179
- t.equal(sequenceRows[0][1].text, 'c ba');
180
- t.equal(sequenceRows[2].length, 2);
181
- t.equal(sequenceRows[2][0].columns[0], 0);
182
- t.equal(sequenceRows[2][0].text, 'gh.i');
183
- } catch (err) {
184
- console.log(err);
185
- }
186
- },
187
- );
188
-
189
- test(
190
- `Headings (${testGroup})`,
191
- async function (t) {
192
- try {
193
- t.plan(4);
194
- const pk = new Proskomma();
195
- importTable(pk);
196
- let query = '{docSets { document(bookCode:"T00") { sequences(types:"table") { id } } } }';
197
- let result = await pk.gqlQuery(query);
198
- t.equal(result.errors, undefined);
199
- const tableSequenceId = result.data.docSets[0].document.sequences[0].id;
200
- query = `{docSets { document(bookCode:"T00") { tableSequence(id:"${tableSequenceId}") { headings } } } }`;
201
- result = await pk.gqlQuery(query);
202
- t.equal(result.errors, undefined);
203
- const headings = result.data.docSets[0].document.tableSequence.headings;
204
- t.equal(headings.length, 2);
205
- t.equal(headings[0], 'firstCol');
206
- } catch (err) {
207
- console.log(err);
208
- }
209
- },
210
- );
211
-
212
- test(
213
- `Filter Rows (${testGroup})`,
214
- async function (t) {
215
- try {
216
- t.plan(11);
217
- const pk = new Proskomma();
218
- importTable(pk);
219
- let query = '{docSets { document(bookCode:"T00") { sequences(types:"table") { id } } } }';
220
- let result = await pk.gqlQuery(query);
221
- t.equal(result.errors, undefined);
222
- const tableSequenceId = result.data.docSets[0].document.sequences[0].id;
223
- query = `{docSets { document(bookCode:"T00") { tableSequence(id:"${tableSequenceId}") { rows(positions:[0, 2]) { text } } } } }`;
224
- result = await pk.gqlQuery(query);
225
- t.equal(result.errors, undefined);
226
- let sequenceRows = result.data.docSets[0].document.tableSequence.rows;
227
- t.equal(sequenceRows.length, 2);
228
- t.equal(sequenceRows[0][0].text, 'ab.c');
229
- t.equal(sequenceRows[1][0].text, 'gh.i');
230
- query = `{docSets { document(bookCode:"T00") { tableSequence(id:"${tableSequenceId}") { rows(matches:[{colN:0 matching:"ab|de"},{colN:1 matching:"ba|gh"}]) { text } } } } }`;
231
- result = await pk.gqlQuery(query);
232
- t.equal(result.errors, undefined);
233
- sequenceRows = result.data.docSets[0].document.tableSequence.rows;
234
- t.equal(sequenceRows.length, 1);
235
- t.equal(sequenceRows[0][0].text, 'ab.c');
236
- query = `{docSets { document(bookCode:"T00") { tableSequence(id:"${tableSequenceId}") { rows(equals:[{colN:0 values:["de.f", "ab.c"]},{colN:1 values:["i hg", "f ed"]}]) { text } } } } }`;
237
- result = await pk.gqlQuery(query);
238
- t.equal(result.errors, undefined);
239
- sequenceRows = result.data.docSets[0].document.tableSequence.rows;
240
- t.equal(sequenceRows.length, 1);
241
- t.equal(sequenceRows[0][0].text, 'de.f');
242
- } catch (err) {
243
- console.log(err);
244
- }
245
- },
246
- );
247
-
248
- test(
249
- `Filter Columns (${testGroup})`,
250
- async function (t) {
251
- try {
252
- t.plan(6);
253
- const pk = new Proskomma();
254
- importTable(pk);
255
- let query = '{docSets { document(bookCode:"T00") { sequences(types:"table") { id } } } }';
256
- let result = await pk.gqlQuery(query);
257
- t.equal(result.errors, undefined);
258
- const tableSequenceId = result.data.docSets[0].document.sequences[0].id;
259
- query = `{docSets { document(bookCode:"T00") { tableSequence(id:"${tableSequenceId}") { rows(columns:0) { text } } } } }`;
260
- result = await pk.gqlQuery(query);
261
- t.equal(result.errors, undefined);
262
- let sequenceRows = result.data.docSets[0].document.tableSequence.rows;
263
- t.equal(sequenceRows.length, 3);
264
- t.equal(sequenceRows[0].length, 1);
265
- t.equal(sequenceRows[0][0].text, 'ab.c');
266
- t.equal(sequenceRows[1][0].text, 'de.f');
267
- } catch (err) {
268
- console.log(err);
269
- }
270
- },
271
- );
272
-
273
- test(
274
- `Import and query TSV as document (${testGroup})`,
275
- async function (t) {
276
- try {
277
- t.plan(6);
278
- const pk = new Proskomma();
279
-
280
- importTSV(
281
- pk,
282
- '../../test_data/tsv/en_tn_66-JUD.tsv',
283
- true,
284
- );
285
-
286
- let query = '{docSets { document(bookCode:"T00") { sequences(types:"table") { id } } } }';
287
- let result = await pk.gqlQuery(query);
288
- t.equal(result.errors, undefined);
289
- const tableSequenceId = result.data.docSets[0].document.sequences[0].id;
290
-
291
- query = `{
292
- docSets {
293
- document(bookCode:"T00") {
294
- tableSequence(id:"${tableSequenceId}") {
295
- headings
296
- rows(equals:[{colN:1 values:"1"}, {colN:2 values:["23", "24"]}] columns:[0, 1, 2, 7, 8]) {
297
- text
298
- }
299
- }
300
- }
301
- }}`;
302
- result = await pk.gqlQuery(query);
303
- t.equal(result.errors, undefined);
304
- const sequenceRows = result.data.docSets[0].document.tableSequence.rows;
305
- // console.log(JSON.stringify(result.data.docSets[0].document.tableSequence, null, 2));
306
- t.equal(sequenceRows.length, 6);
307
- t.equal(sequenceRows[0].length, 5);
308
- t.equal(sequenceRows.filter(r => r[1].text === '1').length, 6);
309
- t.equal(sequenceRows.filter(r => ['23', '24'].includes(r[2].text)).length, 6);
310
- } catch (err) {
311
- console.log(err);
312
- }
313
- },
314
- );
315
-
316
- test(
317
- `Import and query TSV as sequence (${testGroup})`,
318
- async function (t) {
319
- try {
320
- t.plan(6);
321
-
322
- const blockQuery = blocksSpec2Query(
323
- tsvToInputBlock(
324
- fse.readFileSync(path.resolve(__dirname, '../../test_data/tsv/en_tn_66-JUD.tsv')).toString(),
325
- ),
326
- );
327
-
328
- // console.log(blockQuery);
329
-
330
- let query = `mutation { newSequence(` +
331
- ` documentId: "${pkDoc.id}"` +
332
- ` type: "table"` +
333
- ` blocksSpec: ${blockQuery}` +
334
- ` graftToMain: true) }`;
335
-
336
- let result = await pk.gqlQuery(query);
337
- t.equal(result.errors, undefined);
338
-
339
- query = `{
340
- docSets {
341
- documents {
342
- tableSequences {
343
- rows(equals:[{colN:1 values:"1"}, {colN:2 values:["23", "24"]}] columns:[0, 1, 2, 7, 8]) {
344
- text
345
- }
346
- }
347
- }
348
- }}`;
349
- result = await pk.gqlQuery(query);
350
- t.equal(result.errors, undefined);
351
- const sequenceRows = result.data.docSets[0].documents[0].tableSequences[0].rows;
352
- t.equal(sequenceRows.length, 6);
353
- t.equal(sequenceRows[0].length, 5);
354
- t.equal(sequenceRows.filter(r => r[1].text === '1').length, 6);
355
- t.equal(sequenceRows.filter(r => ['23', '24'].includes(r[2].text)).length, 6);
356
- } catch (err) {
357
- console.log(err);
358
- }
359
- },
360
- );
361
-
362
- test(
363
- `Serialize (${testGroup})`,
364
- async function (t) {
365
- try {
366
- t.plan(3);
367
- const pk = new Proskomma();
368
- importTable(pk);
369
- const query = '{ docSets { id } }';
370
- const result = await pk.gqlQuery(query);
371
- const docSetId = result.data.docSets[0].id;
372
- const serialized = pk.serializeSuccinct(docSetId);
373
- t.ok(serialized);
374
- const validationReport = new Validator().validate('proskomma',
375
- 'succinct',
376
- '0.2.0',
377
- serialized
378
- );
379
- t.ok(validationReport.isValid);
380
- t.equal(validationReport.errors, null);
381
- } catch (err) {
382
- console.log(err);
383
- }
384
- },
385
- );
@@ -1,65 +0,0 @@
1
- const test = require('tape');
2
-
3
- const { pkWithDoc } = require('../../lib/load.js');
4
-
5
- const testGroup = 'USX Ref';
6
-
7
- const [pk, doc] = pkWithDoc('../test_data/usx/esg3.usx', {
8
- lang: 'fra',
9
- abbr: 'nfc18',
10
- });
11
-
12
- test(
13
- `Render xt in footnote (${testGroup})`,
14
- async function (t) {
15
- try {
16
- t.plan(3);
17
- let query =
18
- '{ documents { cv(chapter:"3" verses:"1") { items { type subType payload } } } }';
19
- let result = await pk.gqlQuery(query);
20
- t.equal(result.errors, undefined);
21
- const seqId = result.data.documents[0].cv[0].items.filter(i => i.type === 'graft' && i.subType === 'footnote')[0].payload;
22
-
23
- query = `{
24
- document(id:"${doc.id}") {
25
- sequence(id:"${seqId}") {
26
- blocks { items { type subType payload } text(normalizeSpace:true) }
27
- }
28
- }
29
- }`;
30
- result = await pk.gqlQuery(query);
31
- t.equal(result.errors, undefined);
32
- t.ok(result.data.document.sequence.blocks[0].text.includes('1.2-3'));
33
- } catch (err) {
34
- console.log(err);
35
- }
36
- },
37
- );
38
-
39
- test(
40
- `Render xref (${testGroup})`,
41
- async function (t) {
42
- try {
43
- t.plan(3);
44
- let query =
45
- '{ documents { cv(chapter:"3" verses:"1") { items { type subType payload } } } }';
46
- let result = await pk.gqlQuery(query);
47
- t.equal(result.errors, undefined);
48
- const seqId = result.data.documents[0].cv[0].items.filter(i => i.type === 'graft' && i.subType === 'xref')[0].payload;
49
-
50
- query = `{
51
- document(id:"${doc.id}") {
52
- sequence(id:"${seqId}") {
53
- blocks { items { type subType payload } text(normalizeSpace:true) }
54
- }
55
- }
56
- }`;
57
- result = await pk.gqlQuery(query);
58
- t.equal(result.errors, undefined);
59
- t.ok(result.data.document.sequence.blocks[0].text.includes('1.1'));
60
- } catch (err) {
61
- console.log(err);
62
- }
63
- },
64
- );
65
-