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.
- package/esm/wrapper.mjs +1 -1
- package/{index.js → index.cjs} +1 -1
- package/package.json +2 -2
- package/babel.config.js +0 -18
- package/test/code/main/bad.cjs +0 -79
- package/test/code/main/basics.cjs +0 -534
- package/test/code/main/block.cjs +0 -586
- package/test/code/main/block_scope_numbers.cjs +0 -31
- package/test/code/main/blocks_with_atts.cjs +0 -150
- package/test/code/main/blocks_with_cv.cjs +0 -250
- package/test/code/main/break.cjs +0 -73
- package/test/code/main/checksum.cjs +0 -36
- package/test/code/main/cl_global.cjs +0 -35
- package/test/code/main/class_for_fragment.cjs +0 -18
- package/test/code/main/clean_usfm.cjs +0 -46
- package/test/code/main/cp_vp.cjs +0 -158
- package/test/code/main/custom.cjs +0 -124
- package/test/code/main/cv.cjs +0 -249
- package/test/code/main/cvMatching.cjs +0 -155
- package/test/code/main/cv_indexes.cjs +0 -189
- package/test/code/main/cv_navigation.cjs +0 -124
- package/test/code/main/document.cjs +0 -382
- package/test/code/main/empty_blocks.cjs +0 -71
- package/test/code/main/entries.cjs +0 -402
- package/test/code/main/export_lexing_regexes.cjs +0 -19
- package/test/code/main/fig.cjs +0 -67
- package/test/code/main/filter.cjs +0 -222
- package/test/code/main/glossary.cjs +0 -36
- package/test/code/main/graft_headings.cjs +0 -36
- package/test/code/main/graft_introduction.cjs +0 -96
- package/test/code/main/graft_note.cjs +0 -104
- package/test/code/main/graft_rems.cjs +0 -34
- package/test/code/main/graft_sidebars.cjs +0 -62
- package/test/code/main/graft_title.cjs +0 -36
- package/test/code/main/hello.cjs +0 -105
- package/test/code/main/import_document.cjs +0 -22
- package/test/code/main/import_usfm_int.cjs +0 -48
- package/test/code/main/item_groups.cjs +0 -133
- package/test/code/main/items_with_cv.cjs +0 -311
- package/test/code/main/milestone_attributes.cjs +0 -163
- package/test/code/main/mixed_sequence_documents.cjs +0 -137
- package/test/code/main/mixed_sequences.cjs +0 -217
- package/test/code/main/modify_sequence.cjs +0 -29
- package/test/code/main/multiple_chapters.cjs +0 -58
- package/test/code/main/multiple_content.cjs +0 -105
- package/test/code/main/mutate_add.cjs +0 -180
- package/test/code/main/mutate_delete.cjs +0 -236
- package/test/code/main/mutate_rehash.cjs +0 -68
- package/test/code/main/mutate_tags.cjs +0 -90
- package/test/code/main/mutate_update.cjs +0 -538
- package/test/code/main/selectors.cjs +0 -289
- package/test/code/main/sequence.cjs +0 -361
- package/test/code/main/serialize.cjs +0 -104
- package/test/code/main/spans.cjs +0 -51
- package/test/code/main/split_long_tokens.cjs +0 -30
- package/test/code/main/standard_vrs.cjs +0 -76
- package/test/code/main/subclass.cjs +0 -25
- package/test/code/main/table.cjs +0 -119
- package/test/code/main/tags.cjs +0 -248
- package/test/code/main/token_alignment.cjs +0 -84
- package/test/code/main/trees.cjs +0 -211
- package/test/code/main/tribos.cjs +0 -865
- package/test/code/main/tsv.cjs +0 -385
- package/test/code/main/usx_ref.cjs +0 -65
- package/test/code/main/verse_mapping.cjs +0 -252
- package/test/code/main/verse_range.cjs +0 -31
- package/test/code/main/word_likes.cjs +0 -41
- package/test/code/utils/byte_array.cjs +0 -271
- package/test/code/utils/canons.cjs +0 -20
- package/test/code/utils/generate_id.cjs +0 -17
- package/test/code/utils/graft_defs.cjs +0 -16
- package/test/code/utils/inspect.cjs +0 -130
- package/test/code/utils/items.cjs +0 -56
- package/test/code/utils/push_succinct.cjs +0 -69
- package/test/code/utils/scope_defs.cjs +0 -79
- package/test/code/utils/serialize.cjs +0 -28
- package/test/code/utils/splice.cjs +0 -67
- package/test/code/utils/tags.cjs +0 -69
- package/test/code/utils/versification.cjs +0 -249
- package/test/lib/load.js +0 -110
- package/test/skipped_code/diff.js +0 -53
- package/test/test_data/inputBlockSpec/dodson.json +0 -1654
- package/test/test_data/inputBlockSpec/kv.json +0 -326
- package/test/test_data/inputBlockSpec/mk1.json +0 -1019
- package/test/test_data/inputBlockSpec/table.json +0 -170
- package/test/test_data/tree/genealogy.json +0 -55
- package/test/test_data/tree/jude.json +0 -15965
- package/test/test_data/tsv/en_tn_66-JUD.tsv +0 -75
- package/test/test_data/tsv/twl_JUD.tsv +0 -144
- package/test/test_data/usfm/1pe_webbe.usfm +0 -13
- package/test/test_data/usfm/66-JUD-ust.usfm +0 -1089
- package/test/test_data/usfm/78-GALspavbl.usfm +0 -10
- package/test/test_data/usfm/add_test.usfm +0 -15
- package/test/test_data/usfm/backslash.usfm +0 -4
- package/test/test_data/usfm/cl.usfm +0 -14
- package/test/test_data/usfm/cp_vp.usfm +0 -8
- package/test/test_data/usfm/custom.usfm +0 -13
- package/test/test_data/usfm/en_ust_oba.usfm +0 -875
- package/test/test_data/usfm/en_ust_psa_1.usfm +0 -20
- package/test/test_data/usfm/fig.usfm +0 -3
- package/test/test_data/usfm/filter.usfm +0 -7
- package/test/test_data/usfm/footnote.usfm +0 -11
- package/test/test_data/usfm/frt.usfm +0 -4
- package/test/test_data/usfm/headings.usfm +0 -7
- package/test/test_data/usfm/hello.usfm +0 -8
- package/test/test_data/usfm/int.usfm +0 -7
- package/test/test_data/usfm/milestone_attributes.usfm +0 -7
- package/test/test_data/usfm/milestone_attributes_default.usfm +0 -7
- package/test/test_data/usfm/no_break_space.usfm +0 -4
- package/test/test_data/usfm/no_mt.usfm +0 -6
- package/test/test_data/usfm/rems.usfm +0 -6
- package/test/test_data/usfm/section_intros.usfm +0 -26
- package/test/test_data/usfm/sidebars.usfm +0 -25
- package/test/test_data/usfm/slash_in_att.usfm +0 -6
- package/test/test_data/usfm/soft_line_break.usfm +0 -4
- package/test/test_data/usfm/spans.usfm +0 -5
- package/test/test_data/usfm/split_long_tokens.usfm +0 -6
- package/test/test_data/usfm/table.usfm +0 -18
- package/test/test_data/usfm/table_at_end.usfm +0 -11
- package/test/test_data/usfm/table_in_intro.usfm +0 -22
- package/test/test_data/usfm/table_no_end_cells.usfm +0 -18
- package/test/test_data/usfm/tit_kitchen_sink.usfm +0 -73
- package/test/test_data/usfm/titus_template.usfm +0 -58
- package/test/test_data/usfm/ugnt_3jn.usfm +0 -265
- package/test/test_data/usfm/ult_3jn.usfm +0 -335
- package/test/test_data/usfm/unknown.usfm +0 -5
- package/test/test_data/usfm/ust_psa.usfm +0 -29
- package/test/test_data/usfm/ust_psa_verse_ranges.usfm +0 -24
- package/test/test_data/usfm/ust_psa_with_ts.usfm +0 -29
- package/test/test_data/usfm/verse_breaks_in_blocks.usfm +0 -20
- package/test/test_data/usfm/verse_range.usfm +0 -7
- package/test/test_data/usfm/web_ecc.usfm +0 -391
- package/test/test_data/usfm/web_psa51.usfm +0 -71
- package/test/test_data/usfm/whitespace.usfm +0 -12
- package/test/test_data/usfm/xref.usfm +0 -11
- package/test/test_data/usx/bad_element.usx +0 -2
- package/test/test_data/usx/cp_vp.usx +0 -12
- package/test/test_data/usx/diff1.usx +0 -59
- package/test/test_data/usx/diff2.usx +0 -74
- package/test/test_data/usx/douay_rheims_ecc.usx +0 -58
- package/test/test_data/usx/douay_rheims_psa.usx +0 -5366
- package/test/test_data/usx/douay_rheims_psa_40_60.usx +0 -666
- package/test/test_data/usx/douay_rheims_rut.usx +0 -26
- package/test/test_data/usx/esg3.usx +0 -47
- package/test/test_data/usx/fig.usx +0 -6
- package/test/test_data/usx/milestone_attributes.usx +0 -11
- package/test/test_data/usx/not_nfc18_glo.usx +0 -9
- package/test/test_data/usx/not_nfc18_phm.usx +0 -24
- package/test/test_data/usx/opt_break.usx +0 -10
- package/test/test_data/usx/sidebars.usx +0 -29
- package/test/test_data/usx/table.usx +0 -23
- package/test/test_data/usx/web_psa.usx +0 -8489
- package/test/test_data/usx/web_psa150.usx +0 -33
- package/test/test_data/usx/web_psa_40_60.usx +0 -1079
- package/test/test_data/usx/web_rut.usx +0 -95
- package/test/test_data/usx/web_rut_1.usx +0 -17
- package/test/test_data/utils/douay_rheims.vrs +0 -520
- package/test/test_data/utils/douay_rheims_PSA.usx +0 -5366
- package/test/test_data/utils/serialize_example.json +0 -91
- package/test/test_data/utils/truncated_versification.vrs +0 -29
- package/test/test_data/utils/web_rut_items.json +0 -2977
- package/test/test_data/utils/webbe.vrs +0 -395
- package/test/test_data/utils/webbe_PSA.usx +0 -8489
- package/test/test_data/vrs/douay_rheims.vrs +0 -520
- package/test/test_data/vrs/truncated_versification.vrs +0 -27
- package/test/test_data/vrs/webbe.vrs +0 -397
- package/webpack.prod.js +0 -50
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
-
|
|
5
|
-
const testGroup = 'Filter on Parse';
|
|
6
|
-
|
|
7
|
-
const queryToBlock = async (t, filter) => {
|
|
8
|
-
const pk = pkWithDoc('../test_data/usfm/filter.usfm', {
|
|
9
|
-
lang: 'fra',
|
|
10
|
-
abbr: 'hello',
|
|
11
|
-
}, filter)[0];
|
|
12
|
-
const query = `{ documents { mainSequence { blocks { bg { subType } bs { payload } scopeLabels items {type subType payload} } } } }`;
|
|
13
|
-
const result = await pk.gqlQuery(query);
|
|
14
|
-
t.equal(result.errors, undefined);
|
|
15
|
-
return result.data.documents[0].mainSequence.blocks[0];
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const inlineGrafts = block => block.items.filter(i => i.type === 'graft');
|
|
19
|
-
|
|
20
|
-
test(
|
|
21
|
-
`No Filter (${testGroup})`,
|
|
22
|
-
async function (t) {
|
|
23
|
-
try {
|
|
24
|
-
const scopeLabels = [
|
|
25
|
-
'chapter/1',
|
|
26
|
-
'verse/1',
|
|
27
|
-
'verses/1',
|
|
28
|
-
'span/nd',
|
|
29
|
-
'span/it',
|
|
30
|
-
'span/bd',
|
|
31
|
-
'blockTag/p',
|
|
32
|
-
];
|
|
33
|
-
t.plan(6 + scopeLabels.length);
|
|
34
|
-
const block = await queryToBlock(t, {});
|
|
35
|
-
t.equal(block.bg.length, 2);
|
|
36
|
-
t.equal(block.bg[0].subType, 'title');
|
|
37
|
-
t.equal(block.bg[1].subType, 'heading');
|
|
38
|
-
t.equal(block.scopeLabels.length, 7);
|
|
39
|
-
|
|
40
|
-
for (const scopeLabel of scopeLabels) {
|
|
41
|
-
t.ok(block.scopeLabels.includes(scopeLabel));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const inlines = inlineGrafts(block);
|
|
45
|
-
t.equal(inlines.length, 1);
|
|
46
|
-
} catch (err) {
|
|
47
|
-
console.log(err);
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
test(
|
|
53
|
-
`Exclude All Scopes (${testGroup})`,
|
|
54
|
-
async function (t) {
|
|
55
|
-
try {
|
|
56
|
-
t.plan(4);
|
|
57
|
-
const block = await queryToBlock(t, { includeScopes: [] });
|
|
58
|
-
t.equal(block.bg.length, 2);
|
|
59
|
-
t.equal(block.scopeLabels.length, 1);
|
|
60
|
-
const inlines = inlineGrafts(block);
|
|
61
|
-
t.equal(inlines.length, 1);
|
|
62
|
-
} catch (err) {
|
|
63
|
-
console.log(err);
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
test(
|
|
69
|
-
`Exclude All Grafts (${testGroup})`,
|
|
70
|
-
async function (t) {
|
|
71
|
-
try {
|
|
72
|
-
t.plan(4);
|
|
73
|
-
const block = await queryToBlock(t, { includeGrafts: [] });
|
|
74
|
-
t.equal(block.bg.length, 0);
|
|
75
|
-
t.equal(block.scopeLabels.length, 7);
|
|
76
|
-
const inlines = inlineGrafts(block);
|
|
77
|
-
t.equal(inlines.length, 0);
|
|
78
|
-
} catch (err) {
|
|
79
|
-
console.log(err);
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
test(
|
|
85
|
-
`Exclude Everything (${testGroup})`,
|
|
86
|
-
async function (t) {
|
|
87
|
-
try {
|
|
88
|
-
t.plan(4);
|
|
89
|
-
const block = await queryToBlock(t, {
|
|
90
|
-
includeGrafts: [],
|
|
91
|
-
includeScopes: [],
|
|
92
|
-
});
|
|
93
|
-
t.equal(block.bg.length, 0);
|
|
94
|
-
t.equal(block.scopeLabels.length, 1);
|
|
95
|
-
const inlines = inlineGrafts(block);
|
|
96
|
-
t.equal(inlines.length, 0);
|
|
97
|
-
} catch (err) {
|
|
98
|
-
console.log(err);
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
test(
|
|
104
|
-
`Exclude Nothing (${testGroup})`,
|
|
105
|
-
async function (t) {
|
|
106
|
-
try {
|
|
107
|
-
t.plan(4);
|
|
108
|
-
const block = await queryToBlock(t, {
|
|
109
|
-
excludeGrafts: [],
|
|
110
|
-
excludeScopes: [],
|
|
111
|
-
});
|
|
112
|
-
t.equal(block.bg.length, 2);
|
|
113
|
-
t.equal(block.scopeLabels.length, 7);
|
|
114
|
-
const inlines = inlineGrafts(block);
|
|
115
|
-
t.equal(inlines.length, 1);
|
|
116
|
-
} catch (err) {
|
|
117
|
-
console.log(err);
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
test(
|
|
123
|
-
`Include chapter/verse (${testGroup})`,
|
|
124
|
-
async function (t) {
|
|
125
|
-
try {
|
|
126
|
-
const scopeLabels = [
|
|
127
|
-
'chapter/1',
|
|
128
|
-
'verse/1',
|
|
129
|
-
];
|
|
130
|
-
t.plan(2 + scopeLabels.length);
|
|
131
|
-
const block = await queryToBlock(t, { includeScopes: ['chapter', 'verse/'] });
|
|
132
|
-
t.equal(block.scopeLabels.length, 3);
|
|
133
|
-
|
|
134
|
-
for (const scopeLabel of scopeLabels) {
|
|
135
|
-
t.ok(block.scopeLabels.includes(scopeLabel));
|
|
136
|
-
}
|
|
137
|
-
} catch (err) {
|
|
138
|
-
console.log(err);
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
test(
|
|
144
|
-
`Exclude chapter/verse (${testGroup})`,
|
|
145
|
-
async function (t) {
|
|
146
|
-
try {
|
|
147
|
-
const scopeLabels = [
|
|
148
|
-
'verses/1',
|
|
149
|
-
'span/nd',
|
|
150
|
-
'span/it',
|
|
151
|
-
'span/bd',
|
|
152
|
-
];
|
|
153
|
-
t.plan(2 + scopeLabels.length);
|
|
154
|
-
const block = await queryToBlock(t, { excludeScopes: ['chapter', 'verse/'] });
|
|
155
|
-
t.equal(block.scopeLabels.length, 5);
|
|
156
|
-
|
|
157
|
-
for (const scopeLabel of scopeLabels) {
|
|
158
|
-
t.ok(block.scopeLabels.includes(scopeLabel));
|
|
159
|
-
}
|
|
160
|
-
} catch (err) {
|
|
161
|
-
console.log(err);
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
test(
|
|
167
|
-
`Include Title (${testGroup})`,
|
|
168
|
-
async function (t) {
|
|
169
|
-
try {
|
|
170
|
-
t.plan(3);
|
|
171
|
-
const block = await queryToBlock(t, { includeGrafts: ['title'] });
|
|
172
|
-
t.equal(block.bg.length, 1);
|
|
173
|
-
t.equal(block.bg[0].subType, 'title');
|
|
174
|
-
} catch (err) {
|
|
175
|
-
console.log(err);
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
test(
|
|
181
|
-
`Exclude Title (${testGroup})`,
|
|
182
|
-
async function (t) {
|
|
183
|
-
try {
|
|
184
|
-
t.plan(3);
|
|
185
|
-
const block = await queryToBlock(t, { excludeGrafts: ['title'] });
|
|
186
|
-
t.equal(block.bg.length, 1);
|
|
187
|
-
t.equal(block.bg[0].subType, 'heading');
|
|
188
|
-
} catch (err) {
|
|
189
|
-
console.log(err);
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
test(
|
|
195
|
-
`Include Inline (${testGroup})`,
|
|
196
|
-
async function (t) {
|
|
197
|
-
try {
|
|
198
|
-
t.plan(3);
|
|
199
|
-
const block = await queryToBlock(t, { includeGrafts: ['footnote'] });
|
|
200
|
-
t.equal(block.bg.length, 0);
|
|
201
|
-
const inlines = inlineGrafts(block);
|
|
202
|
-
t.equal(inlines.length, 1);
|
|
203
|
-
} catch (err) {
|
|
204
|
-
console.log(err);
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
test(
|
|
210
|
-
`Exclude Inline (${testGroup})`,
|
|
211
|
-
async function (t) {
|
|
212
|
-
try {
|
|
213
|
-
t.plan(3);
|
|
214
|
-
const block = await queryToBlock(t, { excludeGrafts: ['footnote'] });
|
|
215
|
-
t.equal(block.bg.length, 2);
|
|
216
|
-
const inlines = inlineGrafts(block);
|
|
217
|
-
t.equal(inlines.length, 0);
|
|
218
|
-
} catch (err) {
|
|
219
|
-
console.log(err);
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
);
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
-
|
|
5
|
-
const testGroup = 'PT GLO';
|
|
6
|
-
|
|
7
|
-
const pk = pkWithDoc('../test_data/usx/not_nfc18_glo.usx', {
|
|
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', 'GLO'],
|
|
18
|
-
['id', 'GLO'],
|
|
19
|
-
];
|
|
20
|
-
t.plan(2 + (2 * expectedHeaders.length));
|
|
21
|
-
const query = '{ documents { headers { key value } } }';
|
|
22
|
-
const result = await pk.gqlQuery(query);
|
|
23
|
-
t.equal(result.errors, undefined);
|
|
24
|
-
const queryHeaders = result.data.documents[0].headers;
|
|
25
|
-
t.equal(queryHeaders.length, expectedHeaders.length);
|
|
26
|
-
|
|
27
|
-
for (const [expectedKey, expectedValue] of expectedHeaders) {
|
|
28
|
-
const queryTuple = queryHeaders.filter(kv => kv.key === expectedKey);
|
|
29
|
-
t.ok(queryTuple.length === 1);
|
|
30
|
-
t.ok(queryTuple[0].value === expectedValue);
|
|
31
|
-
}
|
|
32
|
-
} catch (err) {
|
|
33
|
-
console.log(err);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
);
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
-
|
|
5
|
-
const testGroup = 'Graft Headings';
|
|
6
|
-
|
|
7
|
-
const pk = pkWithDoc('../test_data/usfm/headings.usfm', {
|
|
8
|
-
lang: 'fra',
|
|
9
|
-
abbr: 'hello',
|
|
10
|
-
})[0];
|
|
11
|
-
|
|
12
|
-
test(
|
|
13
|
-
`Headings (${testGroup})`,
|
|
14
|
-
async function (t) {
|
|
15
|
-
try {
|
|
16
|
-
t.plan(6);
|
|
17
|
-
const query = '{ documents { sequences { id type blocks { bg { subType, payload } text } } mainSequence { id } } }';
|
|
18
|
-
const result = await pk.gqlQuery(query);
|
|
19
|
-
t.equal(result.errors, undefined);
|
|
20
|
-
const sequences = {};
|
|
21
|
-
|
|
22
|
-
for (const seq of result.data.documents[0].sequences) {
|
|
23
|
-
sequences[seq.id] = seq;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const mainSequence = sequences[result.data.documents[0].mainSequence.id];
|
|
27
|
-
t.equal(mainSequence.blocks[0].bg.length, 2);
|
|
28
|
-
t.equal(mainSequence.blocks[0].bg[0].subType, 'title');
|
|
29
|
-
t.equal(sequences[mainSequence.blocks[0].bg[0].payload].blocks[0].text, 'ACTS');
|
|
30
|
-
t.equal(mainSequence.blocks[0].bg[1].subType, 'heading');
|
|
31
|
-
t.equal(sequences[mainSequence.blocks[0].bg[1].payload].blocks[0].text, 'Prologue');
|
|
32
|
-
} catch (err) {
|
|
33
|
-
console.log(err);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
);
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
-
|
|
5
|
-
const testGroup = 'Graft Introduction';
|
|
6
|
-
|
|
7
|
-
const pk = pkWithDoc('../test_data/usx/not_nfc18_phm.usx', {
|
|
8
|
-
lang: 'fra',
|
|
9
|
-
abbr: 'hello',
|
|
10
|
-
})[0];
|
|
11
|
-
const pk2 = pkWithDoc('../test_data/usfm/section_intros.usfm', {
|
|
12
|
-
lang: 'fra',
|
|
13
|
-
abbr: 'hello',
|
|
14
|
-
})[0];
|
|
15
|
-
|
|
16
|
-
test(
|
|
17
|
-
`Main Intro (${testGroup})`,
|
|
18
|
-
async function (t) {
|
|
19
|
-
try {
|
|
20
|
-
t.plan(23);
|
|
21
|
-
const query = '{ documents { sequences { id type blocks { bg { subType, payload } bs { payload } text } } mainSequence { id } } }';
|
|
22
|
-
const result = await pk.gqlQuery(query);
|
|
23
|
-
t.equal(result.errors, undefined);
|
|
24
|
-
const sequences = {};
|
|
25
|
-
|
|
26
|
-
for (const seq of result.data.documents[0].sequences) {
|
|
27
|
-
sequences[seq.id] = seq;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const mainSequence = sequences[result.data.documents[0].mainSequence.id];
|
|
31
|
-
t.equal(Object.keys(sequences).length, 8);
|
|
32
|
-
t.equal(mainSequence.blocks[0].bg.length, 3);
|
|
33
|
-
t.equal(mainSequence.blocks[0].bg[0].subType, 'title');
|
|
34
|
-
t.equal(mainSequence.blocks[0].bg[1].subType, 'introduction');
|
|
35
|
-
t.equal(mainSequence.blocks[0].bg[2].subType, 'heading');
|
|
36
|
-
const introSequence = sequences[mainSequence.blocks[0].bg[1].payload];
|
|
37
|
-
t.equal(introSequence.blocks.length, 3);
|
|
38
|
-
t.equal(introSequence.blocks[0].bs.payload.split('/')[1], 'ip');
|
|
39
|
-
const titleGraft = introSequence.blocks[0].bg[0];
|
|
40
|
-
t.equal(titleGraft.subType, 'title');
|
|
41
|
-
const titleSequence = sequences[titleGraft.payload];
|
|
42
|
-
t.equal(titleSequence.blocks.length, 3);
|
|
43
|
-
t.equal(titleSequence.blocks[0].bs.payload, 'blockTag/imt2');
|
|
44
|
-
t.equal(titleSequence.blocks[1].bs.payload, 'blockTag/imt3');
|
|
45
|
-
t.equal(titleSequence.blocks[2].bs.payload, 'blockTag/imt');
|
|
46
|
-
t.equal(introSequence.blocks[1].bs.payload.split('/')[1], 'ip');
|
|
47
|
-
const headingGraft = introSequence.blocks[1].bg[0];
|
|
48
|
-
t.equal(headingGraft.subType, 'heading');
|
|
49
|
-
const headingSequence = sequences[headingGraft.payload];
|
|
50
|
-
t.equal(headingSequence.blocks.length, 1);
|
|
51
|
-
t.equal(headingSequence.blocks[0].bs.payload, 'blockTag/is');
|
|
52
|
-
t.equal(introSequence.blocks[2].bs.payload.split('/')[1], 'hangingGraft');
|
|
53
|
-
const endTitleGraft = introSequence.blocks[2].bg[0];
|
|
54
|
-
t.equal(endTitleGraft.subType, 'endTitle');
|
|
55
|
-
const endTitleSequence = sequences[endTitleGraft.payload];
|
|
56
|
-
t.equal(endTitleSequence.blocks.length, 3);
|
|
57
|
-
t.equal(endTitleSequence.blocks[0].bs.payload, 'blockTag/imte2');
|
|
58
|
-
t.equal(endTitleSequence.blocks[1].bs.payload, 'blockTag/imte3');
|
|
59
|
-
t.equal(endTitleSequence.blocks[2].bs.payload, 'blockTag/imte');
|
|
60
|
-
} catch (err) {
|
|
61
|
-
console.log(err);
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
test(
|
|
67
|
-
`Section Intro (${testGroup})`,
|
|
68
|
-
async function (t) {
|
|
69
|
-
try {
|
|
70
|
-
t.plan(12);
|
|
71
|
-
const query = '{ documents { sequences { id type blocks { bg { subType, payload } bs { payload } text } } mainSequence { id } } }';
|
|
72
|
-
const result = await pk2.gqlQuery(query);
|
|
73
|
-
t.equal(result.errors, undefined);
|
|
74
|
-
const sequences = {};
|
|
75
|
-
|
|
76
|
-
for (const seq of result.data.documents[0].sequences) {
|
|
77
|
-
sequences[seq.id] = seq;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const mainSequence = sequences[result.data.documents[0].mainSequence.id];
|
|
81
|
-
t.equal(Object.keys(sequences).length, 8);
|
|
82
|
-
t.equal(mainSequence.blocks.length, 2);
|
|
83
|
-
t.equal(mainSequence.blocks[0].bg.length, 1);
|
|
84
|
-
t.equal(mainSequence.blocks[0].bg[0].subType, 'title');
|
|
85
|
-
t.equal(mainSequence.blocks[1].bg.length, 6);
|
|
86
|
-
t.equal(mainSequence.blocks[1].bg[2].subType, 'introduction');
|
|
87
|
-
t.equal(sequences[mainSequence.blocks[1].bg[2].payload].blocks.length, 2);
|
|
88
|
-
t.equal(sequences[mainSequence.blocks[1].bg[2].payload].blocks[0].bs.payload, 'blockTag/ip');
|
|
89
|
-
t.equal(mainSequence.blocks[1].bg[5].subType, 'introduction');
|
|
90
|
-
t.equal(sequences[mainSequence.blocks[1].bg[5].payload].blocks.length, 1);
|
|
91
|
-
t.equal(sequences[mainSequence.blocks[1].bg[5].payload].blocks[0].bs.payload, 'blockTag/ip');
|
|
92
|
-
} catch (err) {
|
|
93
|
-
console.log(err);
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
);
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
-
|
|
5
|
-
const testGroup = 'Graft Notes';
|
|
6
|
-
|
|
7
|
-
const pk = pkWithDoc('../test_data/usfm/footnote.usfm', {
|
|
8
|
-
lang: 'fra',
|
|
9
|
-
abbr: 'hello',
|
|
10
|
-
})[0];
|
|
11
|
-
const pk2 = pkWithDoc('../test_data/usfm/xref.usfm', {
|
|
12
|
-
lang: 'fra',
|
|
13
|
-
abbr: 'hello',
|
|
14
|
-
})[0];
|
|
15
|
-
|
|
16
|
-
test(
|
|
17
|
-
`Footnote (${testGroup})`,
|
|
18
|
-
async function (t) {
|
|
19
|
-
try {
|
|
20
|
-
const expectedScopes = [
|
|
21
|
-
['s', 'inline/f'],
|
|
22
|
-
['s', 'span/ft'],
|
|
23
|
-
['e', 'span/ft'],
|
|
24
|
-
['s', 'span/fqa'],
|
|
25
|
-
['e', 'span/fqa'],
|
|
26
|
-
['s', 'span/ft'],
|
|
27
|
-
['e', 'span/ft'],
|
|
28
|
-
['s', 'span/fqa'],
|
|
29
|
-
['e', 'span/fqa'],
|
|
30
|
-
['s', 'span/ft'],
|
|
31
|
-
['e', 'span/ft'],
|
|
32
|
-
['e', 'inline/f'],
|
|
33
|
-
];
|
|
34
|
-
t.plan(3 + (2 * expectedScopes.length));
|
|
35
|
-
const query = `{ documents { sequences { id type blocks { dump items {type subType payload} } } mainSequence { id } } }`;
|
|
36
|
-
const result = await pk.gqlQuery(query);
|
|
37
|
-
t.equal(result.errors, undefined);
|
|
38
|
-
const sequences = {};
|
|
39
|
-
|
|
40
|
-
for (const seq of result.data.documents[0].sequences) {
|
|
41
|
-
sequences[seq.id] = seq;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const mainSequence = sequences[result.data.documents[0].mainSequence.id];
|
|
45
|
-
t.equal(mainSequence.blocks.length, 5);
|
|
46
|
-
const footnoteCallerBlock = mainSequence.blocks[2];
|
|
47
|
-
const footnoteGrafts = footnoteCallerBlock.items.filter(i => i.subType === 'footnote');
|
|
48
|
-
t.equal(footnoteGrafts.length, 1);
|
|
49
|
-
const footnoteItems = sequences[footnoteGrafts[0].payload].blocks[0].items;
|
|
50
|
-
const scopes = footnoteItems.filter(i => i.type === 'scope');
|
|
51
|
-
let count = 0;
|
|
52
|
-
|
|
53
|
-
for (const [sOrE, expectedLabel] of expectedScopes) {
|
|
54
|
-
t.equal(scopes[count].subType, sOrE === 's' ? 'start' : 'end');
|
|
55
|
-
t.equal(scopes[count].payload, expectedLabel);
|
|
56
|
-
count++;
|
|
57
|
-
}
|
|
58
|
-
} catch (err) {
|
|
59
|
-
console.log(err);
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
test(
|
|
65
|
-
`XRef (${testGroup})`,
|
|
66
|
-
async function (t) {
|
|
67
|
-
try {
|
|
68
|
-
const expectedScopes = [
|
|
69
|
-
['s', 'inline/x'],
|
|
70
|
-
['s', 'span/xo'],
|
|
71
|
-
['e', 'span/xo'],
|
|
72
|
-
['s', 'span/xt'],
|
|
73
|
-
['e', 'span/xt'],
|
|
74
|
-
['e', 'inline/x'],
|
|
75
|
-
];
|
|
76
|
-
t.plan(3 + (2 * expectedScopes.length));
|
|
77
|
-
const query = `{ documents { sequences { id type blocks { items {type subType payload} } } mainSequence { id } } }`;
|
|
78
|
-
const result = await pk2.gqlQuery(query);
|
|
79
|
-
t.equal(result.errors, undefined);
|
|
80
|
-
const sequences = {};
|
|
81
|
-
|
|
82
|
-
for (const seq of result.data.documents[0].sequences) {
|
|
83
|
-
sequences[seq.id] = seq;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const mainSequence = sequences[result.data.documents[0].mainSequence.id];
|
|
87
|
-
t.equal(mainSequence.blocks.length, 1);
|
|
88
|
-
const xrefCallerBlock = mainSequence.blocks[0];
|
|
89
|
-
const xrefGrafts = xrefCallerBlock.items.filter(i => i.subType === 'xref');
|
|
90
|
-
t.equal(xrefGrafts.length, 1);
|
|
91
|
-
const xrefItems = sequences[xrefGrafts[0].payload].blocks[0].items;
|
|
92
|
-
const scopes = xrefItems.filter(i => i.type === 'scope');
|
|
93
|
-
let count = 0;
|
|
94
|
-
|
|
95
|
-
for (const [sOrE, expectedLabel] of expectedScopes) {
|
|
96
|
-
t.equal(scopes[count].subType, sOrE === 's' ? 'start' : 'end');
|
|
97
|
-
t.equal(scopes[count].payload, expectedLabel);
|
|
98
|
-
count++;
|
|
99
|
-
}
|
|
100
|
-
} catch (err) {
|
|
101
|
-
console.log(err);
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
);
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
-
|
|
5
|
-
const testGroup = 'Graft Headings';
|
|
6
|
-
|
|
7
|
-
const pk = pkWithDoc('../test_data/usfm/rems.usfm', {
|
|
8
|
-
lang: 'fra',
|
|
9
|
-
abbr: 'hello',
|
|
10
|
-
})[0];
|
|
11
|
-
|
|
12
|
-
test(
|
|
13
|
-
`REMs (${testGroup})`,
|
|
14
|
-
async function (t) {
|
|
15
|
-
try {
|
|
16
|
-
t.plan(4);
|
|
17
|
-
const query = '{ documents { sequences { id type blocks { bg { subType, payload } text } } mainSequence { id } } }';
|
|
18
|
-
const result = await pk.gqlQuery(query);
|
|
19
|
-
t.equal(result.errors, undefined);
|
|
20
|
-
const sequences = {};
|
|
21
|
-
|
|
22
|
-
for (const seq of result.data.documents[0].sequences) {
|
|
23
|
-
sequences[seq.id] = seq;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const mainSequence = sequences[result.data.documents[0].mainSequence.id];
|
|
27
|
-
t.equal(mainSequence.blocks[0].bg.length, 1);
|
|
28
|
-
t.equal(mainSequence.blocks[0].bg[0].subType, 'remark');
|
|
29
|
-
t.equal(sequences[mainSequence.blocks[0].bg[0].payload].blocks[0].text, 'Need to finish this sentence');
|
|
30
|
-
} catch (err) {
|
|
31
|
-
console.log(err);
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
);
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
-
|
|
5
|
-
const testGroup = 'Graft Sidebars';
|
|
6
|
-
|
|
7
|
-
const pkWithUSX = pkWithDoc('../test_data/usx/sidebars.usx', {
|
|
8
|
-
lang: 'fra',
|
|
9
|
-
abbr: 'hello',
|
|
10
|
-
})[0];
|
|
11
|
-
const pkWithUSFM = pkWithDoc('../test_data/usfm/sidebars.usfm', {
|
|
12
|
-
lang: 'fra',
|
|
13
|
-
abbr: 'hello',
|
|
14
|
-
})[0];
|
|
15
|
-
|
|
16
|
-
const doTest = async (t, pk) => {
|
|
17
|
-
t.plan(12);
|
|
18
|
-
const query = `{ documents { sequences { id blocks { scopeLabels bg { subType, payload } } } mainSequence { id } } }`;
|
|
19
|
-
const result = await pk.gqlQuery(query);
|
|
20
|
-
t.equal(result.errors, undefined);
|
|
21
|
-
const sequences = {};
|
|
22
|
-
|
|
23
|
-
for (const seq of result.data.documents[0].sequences) {
|
|
24
|
-
sequences[seq.id] = seq;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const mainSequence = sequences[result.data.documents[0].mainSequence.id];
|
|
28
|
-
t.equal(mainSequence.blocks.length, 2);
|
|
29
|
-
t.equal(mainSequence.blocks[0].bg.length, 4);
|
|
30
|
-
t.equal(mainSequence.blocks[0].bg[0].subType, 'title');
|
|
31
|
-
t.equal(mainSequence.blocks[0].bg[1].subType, 'introduction');
|
|
32
|
-
t.equal(mainSequence.blocks[0].bg[2].subType, 'sidebar');
|
|
33
|
-
t.equal(mainSequence.blocks[0].bg[3].subType, 'heading');
|
|
34
|
-
t.equal(mainSequence.blocks[1].bg.length, 1);
|
|
35
|
-
t.equal(mainSequence.blocks[1].bg[0].subType, 'sidebar');
|
|
36
|
-
const sb1Sequence = sequences[mainSequence.blocks[0].bg[2].payload];
|
|
37
|
-
t.equal(sb1Sequence.blocks.length, 1);
|
|
38
|
-
t.equal(sb1Sequence.blocks[0].bg.length, 2);
|
|
39
|
-
t.ok(sb1Sequence.blocks[0].scopeLabels.includes('esbCat/Theme'));
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
test(
|
|
43
|
-
`USX (${testGroup})`,
|
|
44
|
-
async function (t) {
|
|
45
|
-
try {
|
|
46
|
-
await doTest(t, pkWithUSX);
|
|
47
|
-
} catch (err) {
|
|
48
|
-
console.log(err);
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
test(
|
|
54
|
-
`USFM (${testGroup})`,
|
|
55
|
-
async function (t) {
|
|
56
|
-
try {
|
|
57
|
-
await doTest(t, pkWithUSFM);
|
|
58
|
-
} catch (err) {
|
|
59
|
-
console.log(err);
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
);
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
-
|
|
5
|
-
const testGroup = 'Graft Title';
|
|
6
|
-
|
|
7
|
-
const pk = pkWithDoc('../test_data/usx/not_nfc18_phm.usx', {
|
|
8
|
-
lang: 'fra',
|
|
9
|
-
abbr: 'hello',
|
|
10
|
-
})[0];
|
|
11
|
-
|
|
12
|
-
test(
|
|
13
|
-
`Title (${testGroup})`,
|
|
14
|
-
async function (t) {
|
|
15
|
-
try {
|
|
16
|
-
t.plan(9);
|
|
17
|
-
const query = '{ documents { sequences { id type blocks { bg { subType, payload } bs { payload } text } } mainSequence { id } } }';
|
|
18
|
-
const result = await pk.gqlQuery(query);
|
|
19
|
-
t.equal(result.errors, undefined);
|
|
20
|
-
const sequences = result.data.documents[0].sequences;
|
|
21
|
-
const mainSequence = sequences.filter(s => s.id === result.data.documents[0].mainSequence.id)[0];
|
|
22
|
-
t.equal(mainSequence.blocks[0].bg[0].subType, 'title');
|
|
23
|
-
const titleSequence = sequences.filter(s => s.id === mainSequence.blocks[0].bg[0].payload)[0];
|
|
24
|
-
t.equal(titleSequence.blocks.length, 2);
|
|
25
|
-
t.equal(titleSequence.blocks[0].bs.payload.split('/')[1], 'mt2');
|
|
26
|
-
t.equal(titleSequence.blocks[1].bs.payload.split('/')[1], 'mt');
|
|
27
|
-
t.equal(mainSequence.blocks[1].bg[0].subType, 'endTitle');
|
|
28
|
-
const endTitleSequence = sequences.filter(s => s.id === mainSequence.blocks[1].bg[0].payload)[0];
|
|
29
|
-
t.equal(endTitleSequence.blocks.length, 2);
|
|
30
|
-
t.equal(endTitleSequence.blocks[0].bs.payload.split('/')[1], 'mte2');
|
|
31
|
-
t.equal(endTitleSequence.blocks[1].bs.payload.split('/')[1], 'mte');
|
|
32
|
-
} catch (err) {
|
|
33
|
-
console.log(err);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
);
|