proskomma-core 0.9.7 → 0.9.12
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/.eslintrc.json +79 -0
- package/.gitattributes +2 -0
- package/babel.config.js +18 -0
- package/docs/_config.yml +1 -0
- package/docs/index.md +3 -0
- package/docs/pk_edit_0_9.odt +0 -0
- package/docs/pk_edit_0_9.pdf +0 -0
- package/docs/proskomma_101_slideshow.odp +0 -0
- package/docs/proskomma_101_slideshow.pdf +0 -0
- package/docs/proskomma_edit_html.png +0 -0
- package/docs/proskomma_edit_html.svg +451 -0
- package/docs/proskomma_edit_reference.png +0 -0
- package/docs/proskomma_edit_reference.svg +349 -0
- package/docs/repo_logo.png +0 -0
- package/esm/package.json +3 -0
- package/esm/wrapper.mjs +5 -0
- package/index.js +6 -0
- package/package.json +19 -17
- package/src/graph/index.cjs +201 -0
- package/src/graph/lib/do_cv.cjs +249 -0
- package/src/graph/lib/dump.cjs +40 -0
- package/src/graph/lib/remake_blocks.cjs +57 -0
- package/src/graph/lib/sequence_chars.cjs +84 -0
- package/src/graph/lib/sort.cjs +39 -0
- package/src/graph/lib/tribos.cjs +97 -0
- package/src/graph/lib/tribos_expression.cjs +556 -0
- package/src/graph/lib/tribos_ohm_UNUSED.cjs +37 -0
- package/src/graph/lib/tribos_step.cjs +434 -0
- package/src/graph/mutations/add.cjs +91 -0
- package/src/graph/mutations/delete.cjs +61 -0
- package/src/graph/mutations/index.cjs +54 -0
- package/src/graph/mutations/rehash.cjs +17 -0
- package/src/graph/mutations/tags.cjs +120 -0
- package/src/graph/mutations/update.cjs +210 -0
- package/src/graph/mutations/versification.cjs +96 -0
- package/src/graph/queries/block.cjs +228 -0
- package/src/graph/queries/cIndex.cjs +87 -0
- package/src/graph/queries/cell.cjs +42 -0
- package/src/graph/queries/cv.cjs +19 -0
- package/src/graph/queries/cvBook.cjs +16 -0
- package/src/graph/queries/cvChapter.cjs +16 -0
- package/src/graph/queries/cvIndex.cjs +47 -0
- package/src/graph/queries/cvNavigation.cjs +116 -0
- package/src/graph/queries/cvVerseElement.cjs +84 -0
- package/src/graph/queries/cvVerses.cjs +14 -0
- package/src/graph/queries/doc_set.cjs +220 -0
- package/src/graph/queries/document.cjs +555 -0
- package/src/graph/queries/idParts.cjs +30 -0
- package/src/graph/queries/index.cjs +151 -0
- package/src/graph/queries/inputBlockSpec.cjs +17 -0
- package/src/graph/queries/inputItemObject.cjs +12 -0
- package/src/graph/queries/input_att_spec.cjs +14 -0
- package/src/graph/queries/input_key_matches.cjs +11 -0
- package/src/graph/queries/input_key_value.cjs +11 -0
- package/src/graph/queries/input_key_values.cjs +11 -0
- package/src/graph/queries/input_selector_spec.cjs +19 -0
- package/src/graph/queries/item.cjs +71 -0
- package/src/graph/queries/itemGroup.cjs +75 -0
- package/src/graph/queries/key_value.cjs +18 -0
- package/src/graph/queries/kv_entry.cjs +21 -0
- package/src/graph/queries/kv_sequence.cjs +151 -0
- package/src/graph/queries/node.cjs +44 -0
- package/src/graph/queries/orig.cjs +11 -0
- package/src/graph/queries/regex_index.cjs +18 -0
- package/src/graph/queries/row_equals_spec.cjs +11 -0
- package/src/graph/queries/row_match_spec.cjs +11 -0
- package/src/graph/queries/selector_spec.cjs +29 -0
- package/src/graph/queries/sequence.cjs +314 -0
- package/src/graph/queries/table_sequence.cjs +192 -0
- package/src/graph/queries/tree_sequence.cjs +58 -0
- package/src/graph/queries/verseNumber.cjs +44 -0
- package/src/graph/queries/verseRange.cjs +11 -0
- package/src/graph/queries/versification.cjs +25 -0
- package/src/index.cjs +583 -0
- package/src/model/doc_set.cjs +389 -0
- package/src/model/doc_set_helpers/block.cjs +232 -0
- package/src/model/doc_set_helpers/enum.cjs +87 -0
- package/src/model/doc_set_helpers/item.cjs +198 -0
- package/src/model/doc_set_helpers/rehash.cjs +53 -0
- package/src/model/doc_set_helpers/selectors.cjs +58 -0
- package/src/model/doc_set_helpers/serialize.cjs +22 -0
- package/src/model/doc_set_helpers/unsuccinctify.cjs +288 -0
- package/src/model/doc_set_helpers/update.cjs +290 -0
- package/src/model/document.cjs +369 -0
- package/src/model/document_helpers/blocks.cjs +135 -0
- package/src/model/document_helpers/chapter_verse.cjs +291 -0
- package/src/model/document_helpers/pre_enums.cjs +67 -0
- package/src/model/document_helpers/sequences.cjs +205 -0
- package/src/model/document_helpers/serialize_succinct.cjs +55 -0
- package/src/model/document_helpers/succinct_filter.cjs +102 -0
- package/src/model/versifications/eng_vrs.cjs +455 -0
- package/src/model/versifications/index.cjs +38 -0
- package/src/model/versifications/lxx_vrs.cjs +950 -0
- package/src/model/versifications/org_vrs.cjs +155 -0
- package/src/model/versifications/rsc_vrs.cjs +342 -0
- package/src/model/versifications/rso_vrs.cjs +541 -0
- package/src/model/versifications/vul_vrs.cjs +835 -0
- package/src/parser/index.cjs +506 -0
- package/src/parser/lexers/index.cjs +11 -0
- package/src/parser/lexers/lexingRegexes.cjs +45 -0
- package/src/parser/lexers/nodes.cjs +123 -0
- package/src/parser/lexers/object_for_fragment.cjs +123 -0
- package/src/parser/lexers/tsv.cjs +45 -0
- package/src/parser/lexers/usfm.cjs +17 -0
- package/src/parser/lexers/usx/index.cjs +7 -0
- package/src/parser/lexers/usx/usx_lexer.cjs +321 -0
- package/src/parser/lib/tokenize.cjs +37 -0
- package/src/parser/model/index.cjs +637 -0
- package/src/parser/parser_specs.cjs +781 -0
- package/src/pipelines/perf2x/index.cjs +7 -0
- package/src/pipelines/perf2x/perf2PkJsonPipeline.json +41 -0
- package/src/pipelines/perf2x/perf2usfmPipeline.json +65 -0
- package/src/transforms/calculateUsfmChapterPositions.cjs +106 -0
- package/src/transforms/index.cjs +9 -0
- package/src/transforms/perf2PkJson.cjs +534 -0
- package/src/transforms/perf2usfm.cjs +294 -0
- package/src/util/byteArray.cjs +251 -0
- package/src/util/canons.cjs +117 -0
- package/src/util/enums.cjs +41 -0
- package/src/util/generateId.cjs +6 -0
- package/src/util/graftDefs.cjs +15 -0
- package/src/util/index.cjs +29 -0
- package/src/util/inspectSuccinct.cjs +59 -0
- package/src/util/itemDefs.cjs +33 -0
- package/src/util/parserConstantDefs.cjs +30 -0
- package/src/util/scopeDefs.cjs +173 -0
- package/src/util/scriptlike/blocksSpec.cjs +192 -0
- package/src/util/scriptlike/dodson_lexicon.xsl +19 -0
- package/src/util/scriptlike/dodson_lexicon_to_entries.cjs +85 -0
- package/src/util/scriptlike/open_scriptures_hebrew_lexicon.xsl +28 -0
- package/src/util/scriptlike/open_scriptures_hebrew_lexicon_to_entries.cjs +85 -0
- package/src/util/succinct.cjs +159 -0
- package/src/util/tags.cjs +28 -0
- package/src/util/tokenDefs.cjs +27 -0
- package/src/util/versification.cjs +364 -0
- package/test/code/main/bad.cjs +79 -0
- package/test/code/main/basics.cjs +534 -0
- package/test/code/main/block.cjs +586 -0
- package/test/code/main/block_scope_numbers.cjs +31 -0
- package/test/code/main/blocks_with_atts.cjs +150 -0
- package/test/code/main/blocks_with_cv.cjs +250 -0
- package/test/code/main/break.cjs +73 -0
- package/test/code/main/checksum.cjs +36 -0
- package/test/code/main/cl_global.cjs +35 -0
- package/test/code/main/class_for_fragment.cjs +18 -0
- package/test/code/main/clean_usfm.cjs +46 -0
- package/test/code/main/cp_vp.cjs +158 -0
- package/test/code/main/custom.cjs +124 -0
- package/test/code/main/cv.cjs +249 -0
- package/test/code/main/cvMatching.cjs +155 -0
- package/test/code/main/cv_indexes.cjs +189 -0
- package/test/code/main/cv_navigation.cjs +124 -0
- package/test/code/main/document.cjs +382 -0
- package/test/code/main/empty_blocks.cjs +71 -0
- package/test/code/main/entries.cjs +402 -0
- package/test/code/main/export_lexing_regexes.cjs +19 -0
- package/test/code/main/fig.cjs +67 -0
- package/test/code/main/filter.cjs +222 -0
- package/test/code/main/glossary.cjs +36 -0
- package/test/code/main/graft_headings.cjs +36 -0
- package/test/code/main/graft_introduction.cjs +96 -0
- package/test/code/main/graft_note.cjs +104 -0
- package/test/code/main/graft_rems.cjs +34 -0
- package/test/code/main/graft_sidebars.cjs +62 -0
- package/test/code/main/graft_title.cjs +36 -0
- package/test/code/main/hello.cjs +105 -0
- package/test/code/main/import_document.cjs +22 -0
- package/test/code/main/import_usfm_int.cjs +48 -0
- package/test/code/main/item_groups.cjs +133 -0
- package/test/code/main/items_with_cv.cjs +311 -0
- package/test/code/main/milestone_attributes.cjs +163 -0
- package/test/code/main/mixed_sequence_documents.cjs +137 -0
- package/test/code/main/mixed_sequences.cjs +217 -0
- package/test/code/main/modify_sequence.cjs +29 -0
- package/test/code/main/multiple_chapters.cjs +58 -0
- package/test/code/main/multiple_content.cjs +105 -0
- package/test/code/main/mutate_add.cjs +180 -0
- package/test/code/main/mutate_delete.cjs +236 -0
- package/test/code/main/mutate_rehash.cjs +68 -0
- package/test/code/main/mutate_tags.cjs +90 -0
- package/test/code/main/mutate_update.cjs +538 -0
- package/test/code/main/selectors.cjs +289 -0
- package/test/code/main/sequence.cjs +361 -0
- package/test/code/main/serialize.cjs +104 -0
- package/test/code/main/spans.cjs +51 -0
- package/test/code/main/split_long_tokens.cjs +30 -0
- package/test/code/main/standard_vrs.cjs +76 -0
- package/test/code/main/subclass.cjs +25 -0
- package/test/code/main/table.cjs +119 -0
- package/test/code/main/tags.cjs +248 -0
- package/test/code/main/token_alignment.cjs +84 -0
- package/test/code/main/trees.cjs +211 -0
- package/test/code/main/tribos.cjs +865 -0
- package/test/code/main/tsv.cjs +385 -0
- package/test/code/main/usx_ref.cjs +65 -0
- package/test/code/main/verse_mapping.cjs +252 -0
- package/test/code/main/verse_range.cjs +31 -0
- package/test/code/main/word_likes.cjs +41 -0
- package/test/code/utils/byte_array.cjs +271 -0
- package/test/code/utils/canons.cjs +20 -0
- package/test/code/utils/generate_id.cjs +17 -0
- package/test/code/utils/graft_defs.cjs +16 -0
- package/test/code/utils/inspect.cjs +130 -0
- package/test/code/utils/items.cjs +56 -0
- package/test/code/utils/push_succinct.cjs +69 -0
- package/test/code/utils/scope_defs.cjs +79 -0
- package/test/code/utils/serialize.cjs +28 -0
- package/test/code/utils/splice.cjs +67 -0
- package/test/code/utils/tags.cjs +69 -0
- package/test/code/utils/versification.cjs +249 -0
- package/test/lib/load.js +110 -0
- package/test/skipped_code/diff.js +53 -0
- package/test/test_data/inputBlockSpec/dodson.json +1654 -0
- package/test/test_data/inputBlockSpec/kv.json +326 -0
- package/test/test_data/inputBlockSpec/mk1.json +1019 -0
- package/test/test_data/inputBlockSpec/table.json +170 -0
- package/test/test_data/tree/genealogy.json +55 -0
- package/test/test_data/tree/jude.json +15965 -0
- package/test/test_data/tsv/en_tn_66-JUD.tsv +75 -0
- package/test/test_data/tsv/twl_JUD.tsv +144 -0
- package/test/test_data/usfm/1pe_webbe.usfm +13 -0
- package/test/test_data/usfm/66-JUD-ust.usfm +1089 -0
- package/test/test_data/usfm/78-GALspavbl.usfm +10 -0
- package/test/test_data/usfm/add_test.usfm +15 -0
- package/test/test_data/usfm/backslash.usfm +4 -0
- package/test/test_data/usfm/cl.usfm +14 -0
- package/test/test_data/usfm/cp_vp.usfm +8 -0
- package/test/test_data/usfm/custom.usfm +13 -0
- package/test/test_data/usfm/en_ust_oba.usfm +875 -0
- package/test/test_data/usfm/en_ust_psa_1.usfm +20 -0
- package/test/test_data/usfm/fig.usfm +3 -0
- package/test/test_data/usfm/filter.usfm +7 -0
- package/test/test_data/usfm/footnote.usfm +11 -0
- package/test/test_data/usfm/frt.usfm +4 -0
- package/test/test_data/usfm/headings.usfm +7 -0
- package/test/test_data/usfm/hello.usfm +8 -0
- package/test/test_data/usfm/int.usfm +7 -0
- package/test/test_data/usfm/milestone_attributes.usfm +7 -0
- package/test/test_data/usfm/milestone_attributes_default.usfm +7 -0
- package/test/test_data/usfm/no_break_space.usfm +4 -0
- package/test/test_data/usfm/no_mt.usfm +6 -0
- package/test/test_data/usfm/rems.usfm +6 -0
- package/test/test_data/usfm/section_intros.usfm +26 -0
- package/test/test_data/usfm/sidebars.usfm +25 -0
- package/test/test_data/usfm/slash_in_att.usfm +6 -0
- package/test/test_data/usfm/soft_line_break.usfm +4 -0
- package/test/test_data/usfm/spans.usfm +5 -0
- package/test/test_data/usfm/split_long_tokens.usfm +6 -0
- package/test/test_data/usfm/table.usfm +18 -0
- package/test/test_data/usfm/table_at_end.usfm +11 -0
- package/test/test_data/usfm/table_in_intro.usfm +22 -0
- package/test/test_data/usfm/table_no_end_cells.usfm +18 -0
- package/test/test_data/usfm/tit_kitchen_sink.usfm +73 -0
- package/test/test_data/usfm/titus_template.usfm +58 -0
- package/test/test_data/usfm/ugnt_3jn.usfm +265 -0
- package/test/test_data/usfm/ult_3jn.usfm +335 -0
- package/test/test_data/usfm/unknown.usfm +5 -0
- package/test/test_data/usfm/ust_psa.usfm +29 -0
- package/test/test_data/usfm/ust_psa_verse_ranges.usfm +24 -0
- package/test/test_data/usfm/ust_psa_with_ts.usfm +29 -0
- package/test/test_data/usfm/verse_breaks_in_blocks.usfm +20 -0
- package/test/test_data/usfm/verse_range.usfm +7 -0
- package/test/test_data/usfm/web_ecc.usfm +391 -0
- package/test/test_data/usfm/web_psa51.usfm +71 -0
- package/test/test_data/usfm/whitespace.usfm +12 -0
- package/test/test_data/usfm/xref.usfm +11 -0
- package/test/test_data/usx/bad_element.usx +2 -0
- package/test/test_data/usx/cp_vp.usx +12 -0
- package/test/test_data/usx/diff1.usx +59 -0
- package/test/test_data/usx/diff2.usx +74 -0
- package/test/test_data/usx/douay_rheims_ecc.usx +58 -0
- package/test/test_data/usx/douay_rheims_psa.usx +5366 -0
- package/test/test_data/usx/douay_rheims_psa_40_60.usx +666 -0
- package/test/test_data/usx/douay_rheims_rut.usx +26 -0
- package/test/test_data/usx/esg3.usx +47 -0
- package/test/test_data/usx/fig.usx +6 -0
- package/test/test_data/usx/milestone_attributes.usx +11 -0
- package/test/test_data/usx/not_nfc18_glo.usx +9 -0
- package/test/test_data/usx/not_nfc18_phm.usx +24 -0
- package/test/test_data/usx/opt_break.usx +10 -0
- package/test/test_data/usx/sidebars.usx +29 -0
- package/test/test_data/usx/table.usx +23 -0
- package/test/test_data/usx/web_psa.usx +8489 -0
- package/test/test_data/usx/web_psa150.usx +33 -0
- package/test/test_data/usx/web_psa_40_60.usx +1079 -0
- package/test/test_data/usx/web_rut.usx +95 -0
- package/test/test_data/usx/web_rut_1.usx +17 -0
- package/test/test_data/utils/douay_rheims.vrs +520 -0
- package/test/test_data/utils/douay_rheims_PSA.usx +5366 -0
- package/test/test_data/utils/serialize_example.json +91 -0
- package/test/test_data/utils/truncated_versification.vrs +29 -0
- package/test/test_data/utils/web_rut_items.json +2977 -0
- package/test/test_data/utils/webbe.vrs +395 -0
- package/test/test_data/utils/webbe_PSA.usx +8489 -0
- package/test/test_data/vrs/douay_rheims.vrs +520 -0
- package/test/test_data/vrs/truncated_versification.vrs +27 -0
- package/test/test_data/vrs/webbe.vrs +397 -0
- package/webpack.prod.js +50 -0
- package/dist/index.js +0 -8
- package/dist/index.js.LICENSE.txt +0 -23
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fse = require('fs-extra');
|
|
3
|
+
const test = require('tape');
|
|
4
|
+
const deepCopy = require('deep-copy-all');
|
|
5
|
+
|
|
6
|
+
const { pkWithDoc, pkWithDocs } = require('../../lib/load.js');
|
|
7
|
+
|
|
8
|
+
const testGroup = 'Verse Mapping';
|
|
9
|
+
|
|
10
|
+
const cleanPk = pkWithDoc('../test_data/usx/web_psa_40_60.usx', {
|
|
11
|
+
lang: 'eng',
|
|
12
|
+
abbr: 'web',
|
|
13
|
+
})[0];
|
|
14
|
+
|
|
15
|
+
const cleanPk2 = pkWithDocs([
|
|
16
|
+
['../test_data/usx/web_psa.usx', {
|
|
17
|
+
lang: 'eng',
|
|
18
|
+
abbr: 'webbe',
|
|
19
|
+
}],
|
|
20
|
+
['../test_data/usx/douay_rheims_psa.usx', {
|
|
21
|
+
lang: 'eng',
|
|
22
|
+
abbr: 'drh',
|
|
23
|
+
}],
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
const pk3 = pkWithDocs([
|
|
27
|
+
['../test_data/usx/web_rut.usx', {
|
|
28
|
+
lang: 'eng',
|
|
29
|
+
abbr: 'webbe',
|
|
30
|
+
}],
|
|
31
|
+
['../test_data/usx/douay_rheims_rut.usx', {
|
|
32
|
+
lang: 'eng',
|
|
33
|
+
abbr: 'drh',
|
|
34
|
+
}],
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
const pk4 = pkWithDocs([
|
|
38
|
+
['../test_data/usfm/web_ecc.usfm', {
|
|
39
|
+
lang: 'eng',
|
|
40
|
+
abbr: 'webbe',
|
|
41
|
+
}],
|
|
42
|
+
['../test_data/usx/douay_rheims_ecc.usx', {
|
|
43
|
+
lang: 'eng',
|
|
44
|
+
abbr: 'drh',
|
|
45
|
+
}],
|
|
46
|
+
]);
|
|
47
|
+
|
|
48
|
+
const addPk2Vrs = async () => {
|
|
49
|
+
let vrs = fse.readFileSync(path.resolve(__dirname, '../../test_data/vrs/webbe.vrs'))
|
|
50
|
+
.toString();
|
|
51
|
+
let mutationQuery = `mutation { setVerseMapping(docSetId: "eng_webbe" vrsSource: """${vrs}""")}`;
|
|
52
|
+
await cleanPk2.gqlQuery(mutationQuery);
|
|
53
|
+
vrs = fse.readFileSync(path.resolve(__dirname, '../../test_data/vrs/douay_rheims.vrs'))
|
|
54
|
+
.toString();
|
|
55
|
+
mutationQuery = `mutation { setVerseMapping(docSetId: "eng_drh" vrsSource: """${vrs}""")}`;
|
|
56
|
+
await cleanPk2.gqlQuery(mutationQuery);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const addPk3Vrs = async () => {
|
|
60
|
+
let vrs = fse.readFileSync(path.resolve(__dirname, '../test_data/vrs/webbe.vrs'))
|
|
61
|
+
.toString();
|
|
62
|
+
let mutationQuery = `mutation { setVerseMapping(docSetId: "eng_webbe" vrsSource: """${vrs}""")}`;
|
|
63
|
+
await pk3.gqlQuery(mutationQuery);
|
|
64
|
+
vrs = fse.readFileSync(path.resolve(__dirname, '../test_data/vrs/douay_rheims.vrs'))
|
|
65
|
+
.toString();
|
|
66
|
+
mutationQuery = `mutation { setVerseMapping(docSetId: "eng_drh" vrsSource: """${vrs}""")}`;
|
|
67
|
+
await pk3.gqlQuery(mutationQuery);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const addPk4Vrs = async () => {
|
|
71
|
+
let vrs = fse.readFileSync(path.resolve(__dirname, '../../test_data/vrs/webbe.vrs'))
|
|
72
|
+
.toString();
|
|
73
|
+
let mutationQuery = `mutation { setVerseMapping(docSetId: "eng_webbe" vrsSource: """${vrs}""")}`;
|
|
74
|
+
await pk4.gqlQuery(mutationQuery);
|
|
75
|
+
vrs = fse.readFileSync(path.resolve(__dirname, '../../test_data/vrs/douay_rheims.vrs'))
|
|
76
|
+
.toString();
|
|
77
|
+
mutationQuery = `mutation { setVerseMapping(docSetId: "eng_drh" vrsSource: """${vrs}""")}`;
|
|
78
|
+
await pk4.gqlQuery(mutationQuery);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
Promise.all([addPk2Vrs(), addPk3Vrs, addPk4Vrs()]).then();
|
|
83
|
+
|
|
84
|
+
test(
|
|
85
|
+
`hasMapping (${testGroup})`,
|
|
86
|
+
async function (t) {
|
|
87
|
+
try {
|
|
88
|
+
t.plan(4);
|
|
89
|
+
const pk = deepCopy(cleanPk);
|
|
90
|
+
const query =
|
|
91
|
+
'{ docSets { id hasMapping } }';
|
|
92
|
+
let result = await pk.gqlQuery(query);
|
|
93
|
+
t.equal(result.errors, undefined);
|
|
94
|
+
t.equal(result.data.docSets[0].hasMapping, false);
|
|
95
|
+
const docSet = pk.docSetById(result.data.docSets[0].id);
|
|
96
|
+
docSet.tags.add('hasMapping');
|
|
97
|
+
result = await pk.gqlQuery(query);
|
|
98
|
+
t.equal(result.errors, undefined);
|
|
99
|
+
t.equal(result.data.docSets[0].hasMapping, true);
|
|
100
|
+
} catch (err) {
|
|
101
|
+
console.log(err);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
test(
|
|
107
|
+
`setVerseMapping/unsetVerseMapping (${testGroup})`,
|
|
108
|
+
async function (t) {
|
|
109
|
+
try {
|
|
110
|
+
t.plan(15);
|
|
111
|
+
const pk = deepCopy(cleanPk);
|
|
112
|
+
let docSetQuery =
|
|
113
|
+
'{ docSets { id hasMapping } }';
|
|
114
|
+
let result = await pk.gqlQuery(docSetQuery);
|
|
115
|
+
t.equal(result.errors, undefined);
|
|
116
|
+
t.equal(result.data.docSets[0].hasMapping, false);
|
|
117
|
+
const docSetId = result.data.docSets[0].id;
|
|
118
|
+
const vrs = fse.readFileSync(path.resolve(__dirname, '../../test_data/vrs/webbe.vrs'))
|
|
119
|
+
.toString();
|
|
120
|
+
let mutationQuery = `mutation { setVerseMapping(docSetId: "${docSetId}" vrsSource: """${vrs}""")}`;
|
|
121
|
+
result = await pk.gqlQuery(mutationQuery);
|
|
122
|
+
t.equal(result.errors, undefined);
|
|
123
|
+
docSetQuery =
|
|
124
|
+
'{ docSets { id hasMapping documents { cvIndex(chapter: 51) { chapter verseNumbers { number orig { book cvs { chapter verse } } } } } } }';
|
|
125
|
+
result = await pk.gqlQuery(docSetQuery);
|
|
126
|
+
t.equal(result.errors, undefined);
|
|
127
|
+
t.equal(result.data.docSets[0].hasMapping, true);
|
|
128
|
+
let v0 = result.data.docSets[0].documents[0].cvIndex.verseNumbers[0];
|
|
129
|
+
t.equal(v0.number, 0);
|
|
130
|
+
t.equal(v0.orig.cvs.length, 2);
|
|
131
|
+
t.equal(v0.orig.cvs[0].verse, 1);
|
|
132
|
+
t.equal(v0.orig.cvs[1].verse, 2);
|
|
133
|
+
mutationQuery = `mutation { unsetVerseMapping(docSetId: "${docSetId}")}`;
|
|
134
|
+
result = await pk.gqlQuery(mutationQuery);
|
|
135
|
+
t.equal(result.errors, undefined);
|
|
136
|
+
result = await pk.gqlQuery(docSetQuery);
|
|
137
|
+
t.equal(result.errors, undefined);
|
|
138
|
+
v0 = result.data.docSets[0].documents[0].cvIndex.verseNumbers[0];
|
|
139
|
+
t.equal(result.data.docSets[0].hasMapping, false);
|
|
140
|
+
t.equal(v0.number, 0);
|
|
141
|
+
t.equal(v0.orig.cvs.length, 1);
|
|
142
|
+
t.equal(v0.orig.cvs[0].verse, 0);
|
|
143
|
+
} catch (err) {
|
|
144
|
+
console.log(err);
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
test(
|
|
150
|
+
`mappedCv between docSets (${testGroup})`,
|
|
151
|
+
async function (t) {
|
|
152
|
+
try {
|
|
153
|
+
t.plan(40);
|
|
154
|
+
const pk = deepCopy(cleanPk2);
|
|
155
|
+
let docSetQuery =
|
|
156
|
+
'{ docSet(id: "eng_webbe") { documents { web: cv(chapter: "48" verses: ["1"]) { text } drh: mappedCv(chapter: "48" verses: ["1"], mappedDocSetId: "eng_drh") { text } } } }';
|
|
157
|
+
let result = await pk.gqlQuery(docSetQuery);
|
|
158
|
+
t.equal(result.errors, undefined);
|
|
159
|
+
t.ok(result.data.docSet.documents[0].web[0].text.startsWith('Great is'));
|
|
160
|
+
t.ok(result.data.docSet.documents[0].drh[0].text.startsWith('Great is'));
|
|
161
|
+
t.ok(result.data.docSet.documents[0].web[0].text.endsWith('mountain.'));
|
|
162
|
+
t.ok(result.data.docSet.documents[0].drh[0].text.endsWith('mountain.'));
|
|
163
|
+
docSetQuery =
|
|
164
|
+
'{ docSet(id: "eng_webbe") { documents { web: cv(chapter: "1" verses: ["1"]) { text } drh: mappedCv(chapter: "1" verses: ["1"], mappedDocSetId: "eng_drh") { text } } } }';
|
|
165
|
+
result = await pk.gqlQuery(docSetQuery);
|
|
166
|
+
t.equal(result.errors, undefined);
|
|
167
|
+
t.ok(result.data.docSet.documents[0].web[0].text.startsWith('Blessed is the man who does'));
|
|
168
|
+
t.ok(result.data.docSet.documents[0].drh[0].text.startsWith('Blessed is the man who hath'));
|
|
169
|
+
t.ok(result.data.docSet.documents[0].web[0].text.endsWith('scoffers;'));
|
|
170
|
+
t.ok(result.data.docSet.documents[0].drh[0].text.endsWith('pestilence.'));
|
|
171
|
+
docSetQuery =
|
|
172
|
+
'{ docSet(id: "eng_webbe") { documents { web: cv(chapter: "10" verses: ["1"]) { text } drh: mappedCv(chapter: "10" verses: ["1"], mappedDocSetId: "eng_drh") { text } } } }';
|
|
173
|
+
result = await pk.gqlQuery(docSetQuery);
|
|
174
|
+
t.equal(result.errors, undefined);
|
|
175
|
+
t.ok(result.data.docSet.documents[0].web[0].text.startsWith('Why do you stand far off'));
|
|
176
|
+
t.ok(result.data.docSet.documents[0].drh[0].text.startsWith('Why, O Lord,'));
|
|
177
|
+
t.ok(result.data.docSet.documents[0].web[0].text.endsWith('times of trouble?'));
|
|
178
|
+
t.ok(result.data.docSet.documents[0].drh[0].text.endsWith('the time of trouble?'));
|
|
179
|
+
docSetQuery =
|
|
180
|
+
'{ docSet(id: "eng_webbe") { documents { web: cv(chapter: "11" verses: ["1"]) { text } drh: mappedCv(chapter: "11" verses: ["1"], mappedDocSetId: "eng_drh") { text } } } }';
|
|
181
|
+
result = await pk.gqlQuery(docSetQuery);
|
|
182
|
+
t.equal(result.errors, undefined);
|
|
183
|
+
t.ok(result.data.docSet.documents[0].web[0].text.startsWith('In the LORD, I take refuge'));
|
|
184
|
+
t.ok(result.data.docSet.documents[0].drh[0].text.startsWith('In the Lord'));
|
|
185
|
+
t.ok(result.data.docSet.documents[0].web[0].text.endsWith('to your mountain”?'));
|
|
186
|
+
t.ok(result.data.docSet.documents[0].drh[0].text.endsWith('like a sparrow?'));
|
|
187
|
+
docSetQuery =
|
|
188
|
+
'{ docSet(id: "eng_webbe") { documents { web: cv(chapter: "11" verses: ["1"]) { text } drh: mappedCv(chapter: "11" verses: ["1"], mappedDocSetId: "eng_drh") { text } } } }';
|
|
189
|
+
result = await pk.gqlQuery(docSetQuery);
|
|
190
|
+
t.equal(result.errors, undefined);
|
|
191
|
+
t.ok(result.data.docSet.documents[0].web[0].text.startsWith('In the LORD, I take refuge'));
|
|
192
|
+
t.ok(result.data.docSet.documents[0].drh[0].text.startsWith('In the Lord'));
|
|
193
|
+
t.ok(result.data.docSet.documents[0].web[0].text.endsWith('to your mountain”?'));
|
|
194
|
+
t.ok(result.data.docSet.documents[0].drh[0].text.endsWith('like a sparrow?'));
|
|
195
|
+
let results = [];
|
|
196
|
+
|
|
197
|
+
for (const docSetId of ['eng_webbe', 'eng_drh']) {
|
|
198
|
+
let mutationQuery = `mutation { unsetVerseMapping(docSetId: "${docSetId}")}`;
|
|
199
|
+
results.push(pk.gqlQuery(mutationQuery));
|
|
200
|
+
}
|
|
201
|
+
results = Promise.all(results);
|
|
202
|
+
docSetQuery =
|
|
203
|
+
'{ docSet(id: "eng_webbe") { documents { web: cv(chapter: "1" verses: ["1"]) { text } drh: mappedCv(chapter: "1" verses: ["1"], mappedDocSetId: "eng_drh") { text } } } }';
|
|
204
|
+
result = await pk.gqlQuery(docSetQuery);
|
|
205
|
+
t.equal(result.errors, undefined);
|
|
206
|
+
t.ok(result.data.docSet.documents[0].web[0].text.startsWith('Blessed is the man who does'));
|
|
207
|
+
t.ok(result.data.docSet.documents[0].drh[0].text.startsWith('Blessed is the man who hath'));
|
|
208
|
+
t.ok(result.data.docSet.documents[0].web[0].text.endsWith('scoffers;'));
|
|
209
|
+
t.ok(result.data.docSet.documents[0].drh[0].text.endsWith('pestilence.'));
|
|
210
|
+
docSetQuery =
|
|
211
|
+
'{ docSet(id: "eng_webbe") { documents { web: cv(chapter: "1" verses: ["1"]) { text } drh: mappedCv(chapter: "1" verses: ["1"], mappedDocSetId: "eng_drh") { text } } } }';
|
|
212
|
+
result = await pk3.gqlQuery(docSetQuery);
|
|
213
|
+
t.equal(result.errors, undefined);
|
|
214
|
+
t.ok(result.data.docSet.documents[0].web[0].text.startsWith('In the days when the judges judged'));
|
|
215
|
+
t.ok(result.data.docSet.documents[0].drh[0].text.startsWith('In the days of one of the judges'));
|
|
216
|
+
t.ok(result.data.docSet.documents[0].web[0].text.endsWith('his two sons. '));
|
|
217
|
+
t.ok(result.data.docSet.documents[0].drh[0].text.endsWith('his two sons. '));
|
|
218
|
+
docSetQuery =
|
|
219
|
+
'{ docSet(id: "eng_webbe") { documents { web: cv(chapter: "1" verses: ["1"]) { text } drh: mappedCv(chapter: "1" verses: ["1"], mappedDocSetId: "eng_drh") { text } } } }';
|
|
220
|
+
result = await pk4.gqlQuery(docSetQuery);
|
|
221
|
+
t.equal(result.errors, undefined);
|
|
222
|
+
t.ok(result.data.docSet.documents[0].web[0].text.startsWith('The words of the Preacher'));
|
|
223
|
+
t.ok(result.data.docSet.documents[0].drh[0].text.startsWith('The words of Ecclesiastes'));
|
|
224
|
+
t.ok(result.data.docSet.documents[0].web[0].text.endsWith('king in Jerusalem:'));
|
|
225
|
+
t.ok(result.data.docSet.documents[0].drh[0].text.endsWith('king of Jerusalem. '));
|
|
226
|
+
} catch (err) {
|
|
227
|
+
console.log(err);
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
test(
|
|
233
|
+
`mappedCvs between docSets (${testGroup})`,
|
|
234
|
+
async function (t) {
|
|
235
|
+
try {
|
|
236
|
+
t.plan(6);
|
|
237
|
+
const pk = deepCopy(cleanPk2);
|
|
238
|
+
let docSetQuery =
|
|
239
|
+
'{ docSet(id: "eng_webbe") { documents { mappedCvs(chapter: "65", mappedDocSetId: "eng_drh") { scopeLabels text } } } }';
|
|
240
|
+
let result = await pk.gqlQuery(docSetQuery);
|
|
241
|
+
t.equal(result.errors, undefined);
|
|
242
|
+
const mappedCVs = result.data.docSet.documents[0].mappedCvs[0][0];
|
|
243
|
+
t.ok(mappedCVs.text.endsWith('began to go out.'));
|
|
244
|
+
t.ok(mappedCVs.scopeLabels.includes('fromChapter/65'));
|
|
245
|
+
t.ok(mappedCVs.scopeLabels.includes('fromVerse/0'));
|
|
246
|
+
t.ok(mappedCVs.scopeLabels.includes('chapter/64'));
|
|
247
|
+
t.ok(mappedCVs.scopeLabels.includes('verse/1'));
|
|
248
|
+
} catch (err) {
|
|
249
|
+
console.log(err);
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const test = require('tape');
|
|
2
|
+
|
|
3
|
+
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
+
|
|
5
|
+
const testGroup = 'Verse Range';
|
|
6
|
+
|
|
7
|
+
const pk = pkWithDoc('../test_data/usfm/verse_range.usfm', {
|
|
8
|
+
lang: 'fra',
|
|
9
|
+
abbr: 'hello',
|
|
10
|
+
})[0];
|
|
11
|
+
|
|
12
|
+
test(
|
|
13
|
+
`Verse and Verses Scopes (${testGroup})`,
|
|
14
|
+
async function (t) {
|
|
15
|
+
try {
|
|
16
|
+
t.plan(6);
|
|
17
|
+
const query =
|
|
18
|
+
'{ documents { mainSequence { blocks { is { payload } } } } }';
|
|
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.equal(block.is.length, 4);
|
|
23
|
+
t.equal(block.is[0].payload, 'chapter/1');
|
|
24
|
+
t.equal(block.is[1].payload, 'verse/1');
|
|
25
|
+
t.equal(block.is[2].payload, 'verse/2');
|
|
26
|
+
t.equal(block.is[3].payload, 'verses/1-2');
|
|
27
|
+
} catch (err) {
|
|
28
|
+
console.log(err);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const test = require('tape');
|
|
2
|
+
|
|
3
|
+
const { pkWithDoc } = require('../../lib/load.js');
|
|
4
|
+
|
|
5
|
+
const testGroup = 'wordLikes';
|
|
6
|
+
|
|
7
|
+
const pk = pkWithDoc('../test_data/usfm/cp_vp.usfm', {
|
|
8
|
+
lang: 'eng',
|
|
9
|
+
abbr: 'hello',
|
|
10
|
+
})[0];
|
|
11
|
+
|
|
12
|
+
test(
|
|
13
|
+
`DocSet (${testGroup})`,
|
|
14
|
+
async function (t) {
|
|
15
|
+
try {
|
|
16
|
+
t.plan(8);
|
|
17
|
+
let query =
|
|
18
|
+
'{ docSets { wordLikes } }';
|
|
19
|
+
let result = await pk.gqlQuery(query);
|
|
20
|
+
t.equal(result.errors, undefined);
|
|
21
|
+
let wordLikes = result.data.docSets[0].wordLikes;
|
|
22
|
+
t.ok(wordLikes.includes('Here'));
|
|
23
|
+
t.false(wordLikes.includes('here'));
|
|
24
|
+
query =
|
|
25
|
+
'{ docSets { wordLikes(coerceCase:"toLower") } }';
|
|
26
|
+
result = await pk.gqlQuery(query);
|
|
27
|
+
t.equal(result.errors, undefined);
|
|
28
|
+
wordLikes = result.data.docSets[0].wordLikes;
|
|
29
|
+
t.ok(wordLikes.includes('here'));
|
|
30
|
+
t.false(wordLikes.includes('Here'));
|
|
31
|
+
query =
|
|
32
|
+
'{ docSets { wordLikes(coerceCase:"toUpper") } }';
|
|
33
|
+
result = await pk.gqlQuery(query);
|
|
34
|
+
t.equal(result.errors, undefined);
|
|
35
|
+
wordLikes = result.data.docSets[0].wordLikes;
|
|
36
|
+
t.ok(wordLikes.includes('HERE'));
|
|
37
|
+
} catch (err) {
|
|
38
|
+
console.log(err);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
);
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
const test = require('tape');
|
|
2
|
+
const { utils } = require('../../../src/index.cjs');
|
|
3
|
+
const ByteArray = utils.ByteArray;
|
|
4
|
+
|
|
5
|
+
const testGroup = 'Byte Array';
|
|
6
|
+
|
|
7
|
+
test(
|
|
8
|
+
`Construct (${testGroup})`,
|
|
9
|
+
function (t) {
|
|
10
|
+
try {
|
|
11
|
+
t.plan(2);
|
|
12
|
+
t.doesNotThrow(() => new ByteArray());
|
|
13
|
+
t.doesNotThrow(() => new ByteArray(10));
|
|
14
|
+
} catch (err) {
|
|
15
|
+
console.log(err);
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
test(
|
|
21
|
+
`Push, Read Byte (${testGroup})`,
|
|
22
|
+
function (t) {
|
|
23
|
+
try {
|
|
24
|
+
t.plan(2);
|
|
25
|
+
const ba = new ByteArray(1);
|
|
26
|
+
t.throws(() => ba.byte(0));
|
|
27
|
+
ba.pushByte(99);
|
|
28
|
+
t.equal(ba.byte(0), 99);
|
|
29
|
+
} catch (err) {
|
|
30
|
+
console.log(err);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
test(
|
|
36
|
+
`Write Byte (${testGroup})`,
|
|
37
|
+
function (t) {
|
|
38
|
+
try {
|
|
39
|
+
t.plan(4);
|
|
40
|
+
const ba = new ByteArray(1);
|
|
41
|
+
ba.pushByte(93);
|
|
42
|
+
t.equal(ba.byte(0), 93);
|
|
43
|
+
t.throws(() => ba.setByte(99, 3));
|
|
44
|
+
ba.setByte(0, 27);
|
|
45
|
+
t.equal(ba.byte(0), 27);
|
|
46
|
+
t.throws(() => ba.setByte(0, 500));
|
|
47
|
+
} catch (err) {
|
|
48
|
+
console.log(err);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
test(
|
|
54
|
+
`Push, Read Bytes (${testGroup})`,
|
|
55
|
+
function (t) {
|
|
56
|
+
try {
|
|
57
|
+
t.plan(5);
|
|
58
|
+
const ba = new ByteArray(10);
|
|
59
|
+
t.throws(() => ba.pushBytes('banana'));
|
|
60
|
+
ba.pushBytes([2, 4, 6, 8]);
|
|
61
|
+
t.equal(ba.byte(0), 2);
|
|
62
|
+
t.equal(ba.byte(2), 6);
|
|
63
|
+
t.equal(ba.bytes(1, 3)[2], 8);
|
|
64
|
+
t.throws(() => ba.bytes(1, 99));
|
|
65
|
+
} catch (err) {
|
|
66
|
+
console.log(err);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
test(
|
|
72
|
+
`Write Bytes (${testGroup})`,
|
|
73
|
+
function (t) {
|
|
74
|
+
try {
|
|
75
|
+
t.plan(3);
|
|
76
|
+
const ba = new ByteArray(5);
|
|
77
|
+
ba.pushBytes([2, 4, 6, 8]);
|
|
78
|
+
t.equal(ba.byte(0), 2);
|
|
79
|
+
ba.setBytes(1, [3, 5, 7]);
|
|
80
|
+
t.throws(() => ba.setBytes(99, [1, 2]));
|
|
81
|
+
t.equal(ba.byte(2), 5);
|
|
82
|
+
} catch (err) {
|
|
83
|
+
console.log(err);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
test(
|
|
89
|
+
`Grow (${testGroup})`,
|
|
90
|
+
function (t) {
|
|
91
|
+
try {
|
|
92
|
+
t.plan(6);
|
|
93
|
+
const ba = new ByteArray(5);
|
|
94
|
+
ba.pushBytes([2, 4, 6, 8, 10]);
|
|
95
|
+
t.equal(ba.length, 5);
|
|
96
|
+
t.equal(ba.byteArray.length, 5);
|
|
97
|
+
ba.pushByte(12);
|
|
98
|
+
t.equal(ba.byteArray.length, 21);
|
|
99
|
+
t.equal(ba.length, 6);
|
|
100
|
+
t.equal(ba.byte(0), 2);
|
|
101
|
+
t.equal(ba.byte(5), 12);
|
|
102
|
+
} catch (err) {
|
|
103
|
+
console.log(err);
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
test(
|
|
109
|
+
`NByte (${testGroup})`,
|
|
110
|
+
function (t) {
|
|
111
|
+
try {
|
|
112
|
+
t.plan(7);
|
|
113
|
+
const ba = new ByteArray();
|
|
114
|
+
ba.pushNByte(127);
|
|
115
|
+
t.equal(ba.byte(0), 127 + 128);
|
|
116
|
+
t.equal(ba.nByte(0), 127);
|
|
117
|
+
ba.pushNByte(130);
|
|
118
|
+
t.equal(ba.byte(1), 2);
|
|
119
|
+
t.equal(ba.byte(2), 1 + 128);
|
|
120
|
+
t.equal(ba.nByte(1), 130);
|
|
121
|
+
t.throws(() => ba.pushNByte('banana'));
|
|
122
|
+
t.throws(() => ba.nByte(99));
|
|
123
|
+
} catch (err) {
|
|
124
|
+
console.log(err);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
test(
|
|
130
|
+
`NBytes (${testGroup})`,
|
|
131
|
+
function (t) {
|
|
132
|
+
try {
|
|
133
|
+
t.plan(6);
|
|
134
|
+
const ba = new ByteArray();
|
|
135
|
+
ba.pushNByte(127);
|
|
136
|
+
ba.pushNByte(17000);
|
|
137
|
+
ba.pushNByte(130);
|
|
138
|
+
const nBytes = ba.nBytes(0, 3);
|
|
139
|
+
t.equal(nBytes.length, 3);
|
|
140
|
+
t.equal(nBytes[0], 127);
|
|
141
|
+
t.equal(nBytes[1], 17000);
|
|
142
|
+
t.equal(nBytes[2], 130);
|
|
143
|
+
t.equal(ba.nBytes(0, 0).length, 0);
|
|
144
|
+
t.throws(() => ba.nBytes(0, 4));
|
|
145
|
+
} catch (err) {
|
|
146
|
+
console.log(err);
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
test(
|
|
152
|
+
`pushNBytes (${testGroup})`,
|
|
153
|
+
function (t) {
|
|
154
|
+
try {
|
|
155
|
+
t.plan(5);
|
|
156
|
+
const ba = new ByteArray();
|
|
157
|
+
ba.pushNBytes([127, 17000, 130]);
|
|
158
|
+
const nBytes = ba.nBytes(0, 3);
|
|
159
|
+
t.equal(nBytes.length, 3);
|
|
160
|
+
t.equal(nBytes[0], 127);
|
|
161
|
+
t.equal(nBytes[1], 17000);
|
|
162
|
+
t.equal(nBytes[2], 130);
|
|
163
|
+
t.throws(() => ba.pushNBytes([1, '2', 3]));
|
|
164
|
+
} catch (err) {
|
|
165
|
+
console.log(err);
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
test(
|
|
171
|
+
`Counted String (${testGroup})`,
|
|
172
|
+
function (t) {
|
|
173
|
+
try {
|
|
174
|
+
t.plan(9);
|
|
175
|
+
let ba = new ByteArray();
|
|
176
|
+
ba.pushCountedString('abc');
|
|
177
|
+
t.equal(ba.byte(0), 3);
|
|
178
|
+
t.equal(ba.byte(1), 'a'.charCodeAt(0));
|
|
179
|
+
t.equal(ba.countedString(0), 'abc');
|
|
180
|
+
ba = new ByteArray();
|
|
181
|
+
ba.pushCountedString('égale');
|
|
182
|
+
t.equal(ba.byte(0), 6);
|
|
183
|
+
t.equal(ba.byte(3), 'g'.charCodeAt(0));
|
|
184
|
+
t.equal(ba.countedString(0), 'égale');
|
|
185
|
+
ba = new ByteArray();
|
|
186
|
+
const musicalChar = String.fromCodePoint(0x1D11E);
|
|
187
|
+
ba.pushCountedString(musicalChar);
|
|
188
|
+
t.equal(ba.byte(0), 4);
|
|
189
|
+
t.equal(ba.countedString(0), musicalChar);
|
|
190
|
+
ba = new ByteArray();
|
|
191
|
+
const hebrew = 'וּבְדֶ֣רֶך';
|
|
192
|
+
ba.pushCountedString(hebrew);
|
|
193
|
+
t.equal(ba.countedString(0), hebrew);
|
|
194
|
+
} catch (err) {
|
|
195
|
+
console.log(err);
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
test(
|
|
201
|
+
`Clear (${testGroup})`,
|
|
202
|
+
function (t) {
|
|
203
|
+
try {
|
|
204
|
+
t.plan(3);
|
|
205
|
+
let ba = new ByteArray();
|
|
206
|
+
ba.pushCountedString('abc');
|
|
207
|
+
t.equal(ba.countedString(0), 'abc');
|
|
208
|
+
ba.clear();
|
|
209
|
+
t.equal(ba.byteArray[0], 0);
|
|
210
|
+
t.equal(ba.length, 0);
|
|
211
|
+
} catch (err) {
|
|
212
|
+
console.log(err);
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
test(
|
|
218
|
+
`nByteLength (${testGroup})`,
|
|
219
|
+
function (t) {
|
|
220
|
+
try {
|
|
221
|
+
t.plan(5);
|
|
222
|
+
let ba = new ByteArray();
|
|
223
|
+
ba.pushNByte((2 ** 7) - 1);
|
|
224
|
+
ba.pushNByte(2 ** 7);
|
|
225
|
+
ba.pushNByte(2 ** 14);
|
|
226
|
+
ba.pushNByte(2 ** 21);
|
|
227
|
+
t.equal(ba.nByteLength(ba.nByte(0)), 1);
|
|
228
|
+
t.equal(ba.nByteLength(ba.nByte(1)), 2);
|
|
229
|
+
t.equal(ba.nByteLength(ba.nByte(3)), 3);
|
|
230
|
+
t.equal(ba.nByteLength(ba.nByte(6)), 4);
|
|
231
|
+
t.throws(() => ba.nByteLength(128 ** 4));
|
|
232
|
+
} catch (err) {
|
|
233
|
+
console.log(err);
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
test(
|
|
239
|
+
`Trim (${testGroup})`,
|
|
240
|
+
function (t) {
|
|
241
|
+
try {
|
|
242
|
+
t.plan(2);
|
|
243
|
+
let ba = new ByteArray(256);
|
|
244
|
+
ba.pushCountedString('abc');
|
|
245
|
+
t.equal(ba.byteArray.length, 256);
|
|
246
|
+
ba.trim();
|
|
247
|
+
t.equal(ba.byteArray.length, 4);
|
|
248
|
+
} catch (err) {
|
|
249
|
+
console.log(err);
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
test(
|
|
255
|
+
`Base64 (${testGroup})`,
|
|
256
|
+
function (t) {
|
|
257
|
+
try {
|
|
258
|
+
t.plan(3);
|
|
259
|
+
let ba = new ByteArray();
|
|
260
|
+
ba.pushCountedString('abc');
|
|
261
|
+
ba.trim();
|
|
262
|
+
let ba2 = new ByteArray();
|
|
263
|
+
ba2.fromBase64(ba.base64());
|
|
264
|
+
t.equal(ba2.byteArray.length, 4);
|
|
265
|
+
t.equal(ba2.length, 4);
|
|
266
|
+
t.equal(ba2.countedString(0), 'abc');
|
|
267
|
+
} catch (err) {
|
|
268
|
+
console.log(err);
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const test = require('tape');
|
|
2
|
+
const { utils } = require('../../../src/index.cjs');
|
|
3
|
+
|
|
4
|
+
const testGroup = 'Generate ID';
|
|
5
|
+
|
|
6
|
+
test(
|
|
7
|
+
`Get an Id (${testGroup})`,
|
|
8
|
+
function (t) {
|
|
9
|
+
try {
|
|
10
|
+
t.plan(utils.canons.ptBookArray.length * 2);
|
|
11
|
+
|
|
12
|
+
for (const ptBook of utils.canons.ptBookArray) {
|
|
13
|
+
t.ok(ptBook.code in utils.canons.ptBooks);
|
|
14
|
+
t.equal(ptBook.code, utils.canons.ptBooks[ptBook.code].code);
|
|
15
|
+
}
|
|
16
|
+
} catch (err) {
|
|
17
|
+
console.log(err);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const test = require('tape');
|
|
2
|
+
const { utils } = require('../../../src/index.cjs');
|
|
3
|
+
|
|
4
|
+
const testGroup = 'Generate ID';
|
|
5
|
+
|
|
6
|
+
test(
|
|
7
|
+
`Get an Id (${testGroup})`,
|
|
8
|
+
function (t) {
|
|
9
|
+
try {
|
|
10
|
+
t.plan(1);
|
|
11
|
+
const id = utils.generateId();
|
|
12
|
+
t.equal(id.length, 12);
|
|
13
|
+
} catch (err) {
|
|
14
|
+
console.log(err);
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const test = require('tape');
|
|
2
|
+
const { utils } = require('../../../src/index.cjs');
|
|
3
|
+
|
|
4
|
+
const testGroup = 'Graft Defs';
|
|
5
|
+
|
|
6
|
+
test(
|
|
7
|
+
`Get an Id (${testGroup})`,
|
|
8
|
+
function (t) {
|
|
9
|
+
try {
|
|
10
|
+
t.plan(1);
|
|
11
|
+
t.equal(utils.graftDefs.graftLocation['footnote'], 'inline');
|
|
12
|
+
} catch (err) {
|
|
13
|
+
console.log(err);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
);
|