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,104 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
const { Validator } = require('proskomma-json-tools');
|
|
3
|
-
|
|
4
|
-
const { Proskomma, utils } = require('../../../src/index.cjs');
|
|
5
|
-
const { unpackEnum } = utils.succinct;
|
|
6
|
-
|
|
7
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
8
|
-
|
|
9
|
-
const testGroup = 'Serialize';
|
|
10
|
-
|
|
11
|
-
const pk = pkWithDoc('../test_data/usx/web_rut.usx', {
|
|
12
|
-
lang: 'fra',
|
|
13
|
-
abbr: 'hello',
|
|
14
|
-
})[0];
|
|
15
|
-
|
|
16
|
-
const pk3 = pkWithDoc('../test_data/usfm/78-GALspavbl.usfm', {
|
|
17
|
-
lang: 'spa',
|
|
18
|
-
abbr: 'vbl',
|
|
19
|
-
})[0];
|
|
20
|
-
|
|
21
|
-
test(
|
|
22
|
-
`Serialize WEB RUT (${testGroup})`,
|
|
23
|
-
async function (t) {
|
|
24
|
-
try {
|
|
25
|
-
t.plan(4);
|
|
26
|
-
const query = '{ docSets { id } }';
|
|
27
|
-
const result = await pk.gqlQuery(query);
|
|
28
|
-
const docSetId = result.data.docSets[0].id;
|
|
29
|
-
const serialized = pk.serializeSuccinct(docSetId);
|
|
30
|
-
t.ok(serialized);
|
|
31
|
-
const validationReport = new Validator().validate('proskomma',
|
|
32
|
-
'succinct',
|
|
33
|
-
'0.2.0',
|
|
34
|
-
serialized
|
|
35
|
-
);
|
|
36
|
-
t.ok(validationReport.isValid);
|
|
37
|
-
t.equal(validationReport.errors, null);
|
|
38
|
-
const wordLikes = unpackEnum(pk.docSets[docSetId].enums['wordLike']);
|
|
39
|
-
t.ok(wordLikes.includes('Ruth'));
|
|
40
|
-
} catch (err) {
|
|
41
|
-
console.log(err);
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
test(
|
|
47
|
-
`Load WEB RUT (${testGroup})`,
|
|
48
|
-
async function (t) {
|
|
49
|
-
try {
|
|
50
|
-
t.plan(11);
|
|
51
|
-
let query = '{ docSets { id } }';
|
|
52
|
-
let result = await pk.gqlQuery(query);
|
|
53
|
-
const docSetId = result.data.docSets[0].id;
|
|
54
|
-
const serialized = pk.serializeSuccinct(docSetId);
|
|
55
|
-
// console.log(JSON.stringify(serialized, null, 2));
|
|
56
|
-
const pk2 = new (Proskomma);
|
|
57
|
-
pk2.loadSuccinctDocSet(serialized);
|
|
58
|
-
t.equal(pk2.nDocSets(), 1);
|
|
59
|
-
t.equal(pk2.nDocuments(), 1);
|
|
60
|
-
const wordLikes = unpackEnum(pk2.docSets[docSetId].enums['wordLike']);
|
|
61
|
-
t.ok(wordLikes.includes('Ruth'));
|
|
62
|
-
query = '{ docSets { id documents { id } } documents { cv(chapter:"1") { text } cv2: cv(chapter:"1" verses:"1") { text } mainSequence { id blocks { text items { type } } } } }';
|
|
63
|
-
result = await pk2.gqlQuery(query);
|
|
64
|
-
t.equal(result.errors, undefined);
|
|
65
|
-
t.equal(result.data.docSets.length, 1);
|
|
66
|
-
t.equal(result.data.docSets[0].documents.length, 1);
|
|
67
|
-
t.equal(result.data.documents.length, 1);
|
|
68
|
-
t.ok(result.data.documents[0].cv[0].text.startsWith('In the days'));
|
|
69
|
-
t.ok(result.data.documents[0].cv2[0].text.startsWith('In the days'));
|
|
70
|
-
const firstBlock = result.data.documents[0].mainSequence.blocks[0];
|
|
71
|
-
t.ok(firstBlock.text.startsWith('In the days when the judges judged'));
|
|
72
|
-
t.throws(() => pk2.loadSuccinctDocSet(serialized), /already loaded/);
|
|
73
|
-
} catch (err) {
|
|
74
|
-
console.log(err);
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
test(
|
|
80
|
-
`Load Text with Accents (${testGroup})`,
|
|
81
|
-
async function (t) {
|
|
82
|
-
try {
|
|
83
|
-
t.plan(7);
|
|
84
|
-
let query = '{ docSets { id } }';
|
|
85
|
-
let result = await pk3.gqlQuery(query);
|
|
86
|
-
const docSetId = result.data.docSets[0].id;
|
|
87
|
-
const serialized = pk3.serializeSuccinct(docSetId);
|
|
88
|
-
const pk2 = new (Proskomma);
|
|
89
|
-
pk2.loadSuccinctDocSet(serialized);
|
|
90
|
-
t.equal(pk2.nDocSets(), 1);
|
|
91
|
-
t.equal(pk2.nDocuments(), 1);
|
|
92
|
-
const wordLikes = unpackEnum(pk2.docSets[docSetId].enums['wordLike']);
|
|
93
|
-
t.ok(wordLikes.includes('Gálatas'));
|
|
94
|
-
query = '{ documents { header(id:"h") headers {key value} } }';
|
|
95
|
-
result = await pk2.gqlQuery(query);
|
|
96
|
-
t.equal(result.errors, undefined);
|
|
97
|
-
t.equal(result.data.documents.length, 1);
|
|
98
|
-
t.ok(result.data.documents[0].header === 'Gálatas');
|
|
99
|
-
t.ok(result.data.documents[0].headers.filter(h => h.key === 'h')[0].value === 'Gálatas');
|
|
100
|
-
} catch (err) {
|
|
101
|
-
console.log(err);
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
);
|
package/test/code/main/spans.cjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
-
|
|
5
|
-
const testGroup = 'Spans';
|
|
6
|
-
|
|
7
|
-
const pk = pkWithDoc('../test_data/usfm/spans.usfm', {
|
|
8
|
-
lang: 'fra',
|
|
9
|
-
abbr: 'hello',
|
|
10
|
-
})[0];
|
|
11
|
-
|
|
12
|
-
test(
|
|
13
|
-
`Spans via Dump (${testGroup})`,
|
|
14
|
-
async function (t) {
|
|
15
|
-
try {
|
|
16
|
-
t.plan(4);
|
|
17
|
-
const query =
|
|
18
|
-
'{ documents { mainSequence { blocks { dump } } } }';
|
|
19
|
-
const result = await pk.gqlQuery(query);
|
|
20
|
-
t.equal(result.errors, undefined);
|
|
21
|
-
const block = result.data.documents[0].mainSequence.blocks[0];
|
|
22
|
-
t.ok(block.dump.includes('+span/nd+|Lord-span/nd-'));
|
|
23
|
-
t.ok(block.dump.includes('+span/it++span/bd+|Joel-span/bd-'));
|
|
24
|
-
t.ok(block.dump.includes('Pethuel-span/it-'));
|
|
25
|
-
} catch (err) {
|
|
26
|
-
console.log(err);
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
test(
|
|
32
|
-
`Spans via items with context (${testGroup})`,
|
|
33
|
-
async function (t) {
|
|
34
|
-
try {
|
|
35
|
-
t.plan(8);
|
|
36
|
-
const query =
|
|
37
|
-
`{ documents { mainSequence { blocks { tokens(includeContext:true) { subType payload position scopes } } } } }`;
|
|
38
|
-
const result = await pk.gqlQuery(query);
|
|
39
|
-
t.equal(result.errors, undefined);
|
|
40
|
-
const joel = result.data.documents[0].mainSequence.blocks[0].tokens.filter(t => t.payload === 'Joel')[0];
|
|
41
|
-
t.ok('position' in joel);
|
|
42
|
-
t.ok('scopes' in joel);
|
|
43
|
-
|
|
44
|
-
for (const scope of ['chapter/1', 'verse/1', 'verses/1', 'span/it', 'span/bd']) {
|
|
45
|
-
t.ok(joel.scopes.includes(scope));
|
|
46
|
-
}
|
|
47
|
-
} catch (err) {
|
|
48
|
-
console.log(err);
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
);
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
-
|
|
5
|
-
const testGroup = 'Split Long Tokens';
|
|
6
|
-
|
|
7
|
-
const pk = pkWithDoc('../test_data/usfm/split_long_tokens.usfm', {
|
|
8
|
-
lang: 'fra',
|
|
9
|
-
abbr: 'hello',
|
|
10
|
-
})[0];
|
|
11
|
-
|
|
12
|
-
test(
|
|
13
|
-
`300-Char Word (${testGroup})`,
|
|
14
|
-
async function (t) {
|
|
15
|
-
try {
|
|
16
|
-
t.plan(6);
|
|
17
|
-
const query = `{ documents { mainSequence { blocks { items {type subType payload} } } } }`;
|
|
18
|
-
const result = await pk.gqlQuery(query);
|
|
19
|
-
t.ok('data' in result);
|
|
20
|
-
const words = result.data.documents[0].mainSequence.blocks[0].items.filter(i => i.subType === 'wordLike');
|
|
21
|
-
t.equal(words.length, 4);
|
|
22
|
-
t.equal(words[0].payload.length, 127);
|
|
23
|
-
t.equal(words[1].payload.length, 127);
|
|
24
|
-
t.equal(words[2].payload.length, 46);
|
|
25
|
-
t.equal(words[3].payload.length, 3);
|
|
26
|
-
} catch (err) {
|
|
27
|
-
console.log(err);
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
);
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const testGroup = 'Standard VRS';
|
|
4
|
-
|
|
5
|
-
const { Proskomma } = require('../../../src/index.cjs');
|
|
6
|
-
|
|
7
|
-
const pk = new Proskomma();
|
|
8
|
-
|
|
9
|
-
test(
|
|
10
|
-
`versifications (${testGroup})`,
|
|
11
|
-
async function (t) {
|
|
12
|
-
try {
|
|
13
|
-
t.plan(3);
|
|
14
|
-
let query = '{versifications { id } }';
|
|
15
|
-
let result = await pk.gqlQuery(query);
|
|
16
|
-
t.equal(result.errors, undefined);
|
|
17
|
-
const versifications = result.data.versifications;
|
|
18
|
-
t.equal(versifications.length, 6);
|
|
19
|
-
t.equal(versifications.filter(v => v.id === 'eng').length, 1);
|
|
20
|
-
} catch (err) {
|
|
21
|
-
console.log(err);
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
test(
|
|
27
|
-
`raw vrs (${testGroup})`,
|
|
28
|
-
async function (t) {
|
|
29
|
-
try {
|
|
30
|
-
t.plan(3);
|
|
31
|
-
let query = '{versification(id: "eng") { id vrs } }';
|
|
32
|
-
let result = await pk.gqlQuery(query);
|
|
33
|
-
t.equal(result.errors, undefined);
|
|
34
|
-
const versification = result.data.versification;
|
|
35
|
-
t.equal(versification.id, 'eng');
|
|
36
|
-
t.ok(versification.vrs.includes('English'));
|
|
37
|
-
} catch (err) {
|
|
38
|
-
console.log(err);
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
test(
|
|
44
|
-
`cvBooks (${testGroup})`,
|
|
45
|
-
async function (t) {
|
|
46
|
-
try {
|
|
47
|
-
t.plan(2);
|
|
48
|
-
let query = '{versification(id: "eng") { cvBooks { bookCode } } }';
|
|
49
|
-
let result = await pk.gqlQuery(query);
|
|
50
|
-
t.equal(result.errors, undefined);
|
|
51
|
-
const cvBooks = result.data.versification.cvBooks;
|
|
52
|
-
t.equal(cvBooks.filter(b => b.bookCode === 'TIT').length, 1);
|
|
53
|
-
} catch (err) {
|
|
54
|
-
console.log(err);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
test(
|
|
60
|
-
`cvBook details (${testGroup})`,
|
|
61
|
-
async function (t) {
|
|
62
|
-
try {
|
|
63
|
-
t.plan(5);
|
|
64
|
-
let query = '{versification(id: "eng") { cvBook(bookCode: "TIT") { bookCode chapters { chapter maxVerse } } } }';
|
|
65
|
-
let result = await pk.gqlQuery(query);
|
|
66
|
-
t.equal(result.errors, undefined);
|
|
67
|
-
const cvBook = result.data.versification.cvBook;
|
|
68
|
-
t.equal(cvBook.bookCode, 'TIT');
|
|
69
|
-
t.equal(cvBook.chapters.length, 3);
|
|
70
|
-
t.equal(cvBook.chapters[0].chapter, 1);
|
|
71
|
-
t.equal(cvBook.chapters[0].maxVerse, 16);
|
|
72
|
-
} catch (err) {
|
|
73
|
-
console.log(err);
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
const { Proskomma } = require('../../../src/index.cjs');
|
|
3
|
-
|
|
4
|
-
const testGroup = 'Subclass test';
|
|
5
|
-
|
|
6
|
-
test(
|
|
7
|
-
`Creating a subclass from lib (${testGroup})`,
|
|
8
|
-
function (t) {
|
|
9
|
-
try {
|
|
10
|
-
t.plan(1);
|
|
11
|
-
t.doesNotThrow(() => {
|
|
12
|
-
class SubClassProskomma extends Proskomma {
|
|
13
|
-
constructor() {
|
|
14
|
-
super();
|
|
15
|
-
this.test = 'test';
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
const sbClass = new SubClassProskomma();
|
|
19
|
-
sbClass.test = 'othertest';
|
|
20
|
-
});
|
|
21
|
-
} catch (err) {
|
|
22
|
-
console.log(err);
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
);
|
package/test/code/main/table.cjs
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
|
|
3
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
-
|
|
5
|
-
const testGroup = 'Tables';
|
|
6
|
-
|
|
7
|
-
const pk = pkWithDoc('../test_data/usx/table.usx', {
|
|
8
|
-
lang: 'fra',
|
|
9
|
-
abbr: 'hello',
|
|
10
|
-
})[0];
|
|
11
|
-
const pk2 = pkWithDoc('../test_data/usfm/table.usfm', {
|
|
12
|
-
lang: 'fra',
|
|
13
|
-
abbr: 'hello',
|
|
14
|
-
})[0];
|
|
15
|
-
const pk3 = pkWithDoc('../test_data/usfm/table_at_end.usfm', {
|
|
16
|
-
lang: 'fra',
|
|
17
|
-
abbr: 'hello',
|
|
18
|
-
})[0];
|
|
19
|
-
const pk4 = pkWithDoc('../test_data/usfm/table_no_end_cells.usfm', {
|
|
20
|
-
lang: 'fra',
|
|
21
|
-
abbr: 'hello',
|
|
22
|
-
})[0];
|
|
23
|
-
|
|
24
|
-
const pk5 = pkWithDoc('../test_data/usfm/table_in_intro.usfm', {
|
|
25
|
-
lang: 'fra',
|
|
26
|
-
abbr: 'hello',
|
|
27
|
-
})[0];
|
|
28
|
-
|
|
29
|
-
const checkResult = (t, result) => {
|
|
30
|
-
const blocks = result.data.documents[0].mainSequence.blocks;
|
|
31
|
-
t.equal(blocks.length, 6);
|
|
32
|
-
t.equal(blocks[0].bs.payload, 'blockTag/p');
|
|
33
|
-
t.false(blocks[0].scopeLabels.includes('table'));
|
|
34
|
-
t.equal(blocks[1].bs.payload, 'blockTag/tr');
|
|
35
|
-
t.ok(blocks[1].scopeLabels.includes('cell/body/left/2'));
|
|
36
|
-
t.ok(blocks[1].scopeLabels.includes('table'));
|
|
37
|
-
t.ok(blocks[2].scopeLabels.includes('cell/body/left/1'));
|
|
38
|
-
t.ok(blocks[2].scopeLabels.includes('cell/body/right/1'));
|
|
39
|
-
t.equal(blocks[5].bs.payload, 'blockTag/p');
|
|
40
|
-
t.false(blocks[5].scopeLabels.includes('table'));
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const query = `{ documents { sequences { id nBlocks } mainSequence { blocks { scopeLabels bs { payload } bg { subType payload } text items { type subType payload } } } } }`;
|
|
44
|
-
|
|
45
|
-
test(
|
|
46
|
-
`USX (${testGroup})`,
|
|
47
|
-
async function (t) {
|
|
48
|
-
try {
|
|
49
|
-
t.plan(11);
|
|
50
|
-
const result = await pk.gqlQuery(query);
|
|
51
|
-
t.equal(result.errors, undefined);
|
|
52
|
-
checkResult(t, result);
|
|
53
|
-
} catch (err) {
|
|
54
|
-
console.log(err);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
test(
|
|
60
|
-
`USFM (${testGroup})`,
|
|
61
|
-
async function (t) {
|
|
62
|
-
try {
|
|
63
|
-
t.plan(11);
|
|
64
|
-
const result = await pk2.gqlQuery(query);
|
|
65
|
-
t.equal(result.errors, undefined);
|
|
66
|
-
checkResult(t, result);
|
|
67
|
-
} catch (err) {
|
|
68
|
-
console.log(err);
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
test(
|
|
74
|
-
`USFM in intro (${testGroup})`,
|
|
75
|
-
async function (t) {
|
|
76
|
-
try {
|
|
77
|
-
t.plan(4);
|
|
78
|
-
const result = await pk5.gqlQuery(query);
|
|
79
|
-
t.equal(result.errors, undefined);
|
|
80
|
-
const mainSequence = result.data.documents[0].mainSequence;
|
|
81
|
-
t.equal(mainSequence.blocks.length, 1);
|
|
82
|
-
const firstMainBlock = mainSequence.blocks[0];
|
|
83
|
-
t.equal(firstMainBlock.text, 'First verse!');
|
|
84
|
-
const introId = firstMainBlock.bg.filter(g => g.subType === 'introduction')[0].payload;
|
|
85
|
-
t.equal(result.data.documents[0].sequences.filter(s => s.id === introId)[0].nBlocks, 6);
|
|
86
|
-
} catch (err) {
|
|
87
|
-
console.log(err);
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
test(
|
|
93
|
-
`USFM no cell end tags (${testGroup})`,
|
|
94
|
-
async function (t) {
|
|
95
|
-
try {
|
|
96
|
-
t.plan(11);
|
|
97
|
-
const result = await pk4.gqlQuery(query);
|
|
98
|
-
t.equal(result.errors, undefined);
|
|
99
|
-
checkResult(t, result);
|
|
100
|
-
} catch (err) {
|
|
101
|
-
console.log(err);
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
test(
|
|
107
|
-
`USFM Table at End of Doc (${testGroup})`,
|
|
108
|
-
async function (t) {
|
|
109
|
-
try {
|
|
110
|
-
t.plan(2);
|
|
111
|
-
const result = await pk3.gqlQuery(query);
|
|
112
|
-
t.equal(result.errors, undefined);
|
|
113
|
-
const lastBlockItems = result.data.documents[0].mainSequence.blocks[2].items;
|
|
114
|
-
t.equal(lastBlockItems.filter(i => i.subType === 'end' && i.payload === 'table').length, 1);
|
|
115
|
-
} catch (err) {
|
|
116
|
-
console.log(err);
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
);
|
package/test/code/main/tags.cjs
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
const test = require('tape');
|
|
2
|
-
const { utils } = require('../../../src/index.cjs');
|
|
3
|
-
const { validateTags } = utils.tags;
|
|
4
|
-
const { pkWithDoc } = require('../../lib/load.js');
|
|
5
|
-
|
|
6
|
-
const pk = pkWithDoc('../test_data/usx/web_rut.usx', {
|
|
7
|
-
lang: 'eng',
|
|
8
|
-
abbr: 'web',
|
|
9
|
-
}, {}, {}, [], ['frob', 'frob2'])[0];
|
|
10
|
-
pk.docSetList()[0].tags.add('foo');
|
|
11
|
-
pk.docSetList()[0].tags.add('foo2');
|
|
12
|
-
const document = Object.values(pk.documents)[0];
|
|
13
|
-
document.sequences[document.mainId].tags.add('banana');
|
|
14
|
-
document.sequences[document.mainId].tags.add('split');
|
|
15
|
-
|
|
16
|
-
const testGroup = 'Graph Tags';
|
|
17
|
-
|
|
18
|
-
test(
|
|
19
|
-
`DocSet accessors (${testGroup})`,
|
|
20
|
-
async function (t) {
|
|
21
|
-
try {
|
|
22
|
-
t.plan(5);
|
|
23
|
-
const query = '{ docSets { tags hasFoo: hasTag(tagName:"foo") hasBaa: hasTag(tagName:"baa")} }';
|
|
24
|
-
const result = await pk.gqlQuery(query);
|
|
25
|
-
t.equal(result.errors, undefined);
|
|
26
|
-
const docSet = result.data.docSets[0];
|
|
27
|
-
t.equal(docSet.tags.length, 2);
|
|
28
|
-
t.ok(docSet.tags.includes('foo'));
|
|
29
|
-
t.ok(docSet.hasFoo);
|
|
30
|
-
t.false(docSet.hasBaa);
|
|
31
|
-
} catch (err) {
|
|
32
|
-
console.log(err);
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
test(
|
|
38
|
-
`DocSet selectors (${testGroup})`,
|
|
39
|
-
async function (t) {
|
|
40
|
-
try {
|
|
41
|
-
t.plan(8);
|
|
42
|
-
let query = '{ docSets(withTags:"foo" withoutTags:"oof") { id } }';
|
|
43
|
-
let result = await pk.gqlQuery(query);
|
|
44
|
-
t.equal(result.errors, undefined);
|
|
45
|
-
t.equal(result.data.docSets.length, 1);
|
|
46
|
-
query = '{ docSets(withTags:["foo" "foo2"]) { id } }';
|
|
47
|
-
result = await pk.gqlQuery(query);
|
|
48
|
-
t.equal(result.errors, undefined);
|
|
49
|
-
t.equal(result.data.docSets.length, 1);
|
|
50
|
-
query = '{ docSets(withTags:["foo" "oof"]) { id } }';
|
|
51
|
-
result = await pk.gqlQuery(query);
|
|
52
|
-
t.equal(result.errors, undefined);
|
|
53
|
-
t.equal(result.data.docSets.length, 0);
|
|
54
|
-
query = '{ docSets(withoutTags:["foo" "oof"]) { id } }';
|
|
55
|
-
result = await pk.gqlQuery(query);
|
|
56
|
-
t.equal(result.errors, undefined);
|
|
57
|
-
t.equal(result.data.docSets.length, 0);
|
|
58
|
-
} catch (err) {
|
|
59
|
-
console.log(err);
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
test(
|
|
65
|
-
`Document accessors (${testGroup})`,
|
|
66
|
-
async function (t) {
|
|
67
|
-
try {
|
|
68
|
-
t.plan(5);
|
|
69
|
-
const query = '{ docSets { documents { tags hasFrob: hasTag(tagName:"frob") hasBrof: hasTag(tagName:"brof")} } }';
|
|
70
|
-
const result = await pk.gqlQuery(query);
|
|
71
|
-
t.equal(result.errors, undefined);
|
|
72
|
-
const document = result.data.docSets[0].documents[0];
|
|
73
|
-
t.equal(document.tags.length, 2);
|
|
74
|
-
t.ok(document.tags.includes('frob'));
|
|
75
|
-
t.ok(document.hasFrob);
|
|
76
|
-
t.false(document.hasBrof);
|
|
77
|
-
} catch (err) {
|
|
78
|
-
console.log(err);
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
test(
|
|
84
|
-
`Root-level Document selectors (${testGroup})`,
|
|
85
|
-
async function (t) {
|
|
86
|
-
try {
|
|
87
|
-
t.plan(8);
|
|
88
|
-
let query = '{ documents(withTags:"frob" withoutTags:"brof") { id } }';
|
|
89
|
-
let result = await pk.gqlQuery(query);
|
|
90
|
-
t.equal(result.errors, undefined);
|
|
91
|
-
t.equal(result.data.documents.length, 1);
|
|
92
|
-
query = '{ documents(withTags:["frob" "frob2"]) { id } }';
|
|
93
|
-
result = await pk.gqlQuery(query);
|
|
94
|
-
t.equal(result.errors, undefined);
|
|
95
|
-
t.equal(result.data.documents.length, 1);
|
|
96
|
-
query = '{ documents(withTags:["frob" "brof"]) { id } }';
|
|
97
|
-
result = await pk.gqlQuery(query);
|
|
98
|
-
t.equal(result.errors, undefined);
|
|
99
|
-
t.equal(result.data.documents.length, 0);
|
|
100
|
-
query = '{ documents(withoutTags:["frob" "brof"]) { id } }';
|
|
101
|
-
result = await pk.gqlQuery(query);
|
|
102
|
-
t.equal(result.errors, undefined);
|
|
103
|
-
t.equal(result.data.documents.length, 0);
|
|
104
|
-
} catch (err) {
|
|
105
|
-
console.log(err);
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
test(
|
|
111
|
-
`Document in docSet selectors (${testGroup})`,
|
|
112
|
-
async function (t) {
|
|
113
|
-
try {
|
|
114
|
-
t.plan(8);
|
|
115
|
-
let query = '{ docSet(id:"eng_web") { documents(withTags:"frob" withoutTags:"brof") { id } } }';
|
|
116
|
-
let result = await pk.gqlQuery(query);
|
|
117
|
-
t.equal(result.errors, undefined);
|
|
118
|
-
t.equal(result.data.docSet.documents.length, 1);
|
|
119
|
-
query = '{ docSet(id:"eng_web") { documents(withTags:["frob" "frob2"]) { id } } }';
|
|
120
|
-
result = await pk.gqlQuery(query);
|
|
121
|
-
t.equal(result.errors, undefined);
|
|
122
|
-
t.equal(result.data.docSet.documents.length, 1);
|
|
123
|
-
query = '{ docSet(id:"eng_web") { documents(withTags:["frob" "brof"]) { id } } }';
|
|
124
|
-
result = await pk.gqlQuery(query);
|
|
125
|
-
t.equal(result.errors, undefined);
|
|
126
|
-
t.equal(result.data.docSet.documents.length, 0);
|
|
127
|
-
query = '{ docSet(id:"eng_web") { documents(withoutTags:["frob" "brof"]) { id } } }';
|
|
128
|
-
result = await pk.gqlQuery(query);
|
|
129
|
-
t.equal(result.errors, undefined);
|
|
130
|
-
t.equal(result.data.docSet.documents.length, 0);
|
|
131
|
-
} catch (err) {
|
|
132
|
-
console.log(err);
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
test(
|
|
138
|
-
`Sequence accessors (${testGroup})`,
|
|
139
|
-
async function (t) {
|
|
140
|
-
try {
|
|
141
|
-
t.plan(5);
|
|
142
|
-
const query = '{ docSets { documents { mainSequence { tags hasBanana: hasTag(tagName:"banana") hasApple: hasTag(tagName:"apple") } } } }';
|
|
143
|
-
const result = await pk.gqlQuery(query);
|
|
144
|
-
t.equal(result.errors, undefined);
|
|
145
|
-
const sequence = result.data.docSets[0].documents[0].mainSequence;
|
|
146
|
-
t.equal(sequence.tags.length, 2);
|
|
147
|
-
t.ok(sequence.tags.includes('banana'));
|
|
148
|
-
t.ok(sequence.hasBanana);
|
|
149
|
-
t.false(sequence.hasApple);
|
|
150
|
-
} catch (err) {
|
|
151
|
-
console.log(err);
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
test(
|
|
157
|
-
`Sequence selectors (${testGroup})`,
|
|
158
|
-
async function (t) {
|
|
159
|
-
try {
|
|
160
|
-
t.plan(8);
|
|
161
|
-
let query = '{ documents { sequences(withTags:"banana" withoutTags:"melba") { id } } } ';
|
|
162
|
-
let result = await pk.gqlQuery(query);
|
|
163
|
-
t.equal(result.errors, undefined);
|
|
164
|
-
t.equal(result.data.documents[0].sequences.length, 1);
|
|
165
|
-
query = '{ documents { sequences(withTags: ["banana" "split"]) { id } } }';
|
|
166
|
-
result = await pk.gqlQuery(query);
|
|
167
|
-
t.equal(result.errors, undefined);
|
|
168
|
-
t.equal(result.data.documents[0].sequences.length, 1);
|
|
169
|
-
query = '{ documents { sequences(withTags: ["banana" "melba"]) { id } } }';
|
|
170
|
-
result = await pk.gqlQuery(query);
|
|
171
|
-
t.equal(result.errors, undefined);
|
|
172
|
-
t.equal(result.data.documents[0].sequences.length, 0);
|
|
173
|
-
query = '{ documents { sequences(withTags:"banana" withoutTags: ["peach" "split"]) { id } } }';
|
|
174
|
-
result = await pk.gqlQuery(query);
|
|
175
|
-
t.equal(result.errors, undefined);
|
|
176
|
-
t.equal(result.data.documents[0].sequences.length, 0);
|
|
177
|
-
} catch (err) {
|
|
178
|
-
console.log(err);
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
test(
|
|
184
|
-
`Throw on bad tag format (${testGroup})`,
|
|
185
|
-
// Destructive!
|
|
186
|
-
function (t) {
|
|
187
|
-
try {
|
|
188
|
-
t.plan(2);
|
|
189
|
-
const importFn = () =>
|
|
190
|
-
pkWithDoc('../test_data/usx/web_rut.usx', {
|
|
191
|
-
lang: 'eng',
|
|
192
|
-
abbr: 'ust',
|
|
193
|
-
}, {}, {}, [], ['FROB']);
|
|
194
|
-
t.throws(importFn, /Tag 'FROB' is not valid/);
|
|
195
|
-
const addTagFn = () => {
|
|
196
|
-
pk.docSetList()[0].tags.add('FROB');
|
|
197
|
-
validateTags(pk.docSetList()[0].tags);
|
|
198
|
-
};
|
|
199
|
-
t.throws(addTagFn, /Tag 'FROB' is not valid/);
|
|
200
|
-
} catch (err) {
|
|
201
|
-
console.log(err);
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
);
|
|
205
|
-
|
|
206
|
-
test(
|
|
207
|
-
`Support colon tag format (${testGroup})`,
|
|
208
|
-
// Destructive!
|
|
209
|
-
function (t) {
|
|
210
|
-
try {
|
|
211
|
-
t.plan(2);
|
|
212
|
-
const importFn = () =>
|
|
213
|
-
pkWithDoc('../test_data/usx/web_rut.usx', {
|
|
214
|
-
lang: 'eng',
|
|
215
|
-
abbr: 'ust',
|
|
216
|
-
}, {}, {}, [], ['FROB']);
|
|
217
|
-
t.throws(importFn, /Tag 'FROB' is not valid/);
|
|
218
|
-
const addTagFn = () => {
|
|
219
|
-
pk.docSetList()[0].tags.delete('FROB');
|
|
220
|
-
pk.docSetList()[0].tags.add('frob:Fooie!! §');
|
|
221
|
-
validateTags(pk.docSetList()[0].tags);
|
|
222
|
-
};
|
|
223
|
-
t.doesNotThrow(addTagFn);
|
|
224
|
-
} catch (err) {
|
|
225
|
-
console.log(err);
|
|
226
|
-
}
|
|
227
|
-
},
|
|
228
|
-
);
|
|
229
|
-
|
|
230
|
-
test(
|
|
231
|
-
`tagsKv on docSet (${testGroup})`,
|
|
232
|
-
// Relies on destructive tests above
|
|
233
|
-
function (t) {
|
|
234
|
-
try {
|
|
235
|
-
t.plan(5);
|
|
236
|
-
pk.docSetList()[0].tags.add('baa');
|
|
237
|
-
const result = pk.gqlQuerySync('{ docSets { tagsKv { key value } } }');
|
|
238
|
-
t.equal(result.errors, undefined);
|
|
239
|
-
const tagsKv = result.data.docSets[0].tagsKv;
|
|
240
|
-
t.equal(tagsKv.filter(kv => kv.key === 'baa').length, 1);
|
|
241
|
-
t.equal(tagsKv.filter(kv => kv.key === 'frob').length, 1);
|
|
242
|
-
t.equal(tagsKv.filter(kv => kv.key === 'baa')[0].value, '');
|
|
243
|
-
t.ok(tagsKv.filter(kv => kv.key === 'frob')[0].value.startsWith('Fooie'));
|
|
244
|
-
} catch (err) {
|
|
245
|
-
console.log(err);
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
);
|