@helloao/tools 0.0.4 → 0.0.6-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +6 -6
  2. package/dist/cjs/generation/api.cjs +240 -0
  3. package/dist/cjs/generation/api.cjs.map +7 -0
  4. package/dist/cjs/generation/audio.cjs +83 -0
  5. package/dist/cjs/generation/audio.cjs.map +7 -0
  6. package/dist/cjs/generation/book-order.cjs +508 -0
  7. package/dist/cjs/generation/book-order.cjs.map +7 -0
  8. package/dist/cjs/generation/common-types.cjs +17 -0
  9. package/dist/cjs/generation/common-types.cjs.map +7 -0
  10. package/dist/cjs/generation/dataset.cjs +158 -0
  11. package/dist/cjs/generation/dataset.cjs.map +7 -0
  12. package/dist/cjs/generation/index.cjs +51 -0
  13. package/dist/cjs/generation/index.cjs.map +7 -0
  14. package/dist/cjs/index.cjs +45 -0
  15. package/dist/cjs/index.cjs.map +7 -0
  16. package/dist/cjs/parser/codex-parser.cjs +176 -0
  17. package/dist/cjs/parser/codex-parser.cjs.map +7 -0
  18. package/dist/cjs/parser/index.cjs +48 -0
  19. package/dist/cjs/parser/index.cjs.map +7 -0
  20. package/dist/cjs/parser/iterators.cjs +204 -0
  21. package/dist/cjs/parser/iterators.cjs.map +7 -0
  22. package/dist/cjs/parser/types.cjs +17 -0
  23. package/dist/cjs/parser/types.cjs.map +7 -0
  24. package/dist/cjs/parser/usfm-parser.cjs +791 -0
  25. package/dist/cjs/parser/usfm-parser.cjs.map +7 -0
  26. package/dist/cjs/parser/usx-parser.cjs +471 -0
  27. package/dist/cjs/parser/usx-parser.cjs.map +7 -0
  28. package/dist/cjs/utils.cjs +85 -0
  29. package/dist/cjs/utils.cjs.map +7 -0
  30. package/dist/esm/generation/api.js +198 -0
  31. package/dist/esm/generation/api.js.map +7 -0
  32. package/dist/esm/generation/audio.js +53 -0
  33. package/dist/esm/generation/audio.js.map +7 -0
  34. package/dist/esm/generation/book-order.js +478 -0
  35. package/dist/esm/generation/book-order.js.map +7 -0
  36. package/dist/esm/generation/common-types.js +2 -0
  37. package/dist/esm/generation/common-types.js.map +7 -0
  38. package/dist/esm/generation/dataset.js +132 -0
  39. package/dist/esm/generation/dataset.js.map +7 -0
  40. package/dist/esm/generation/index.js +8 -0
  41. package/dist/esm/generation/index.js.map +7 -0
  42. package/dist/esm/index.js +6 -0
  43. package/dist/esm/index.js.map +7 -0
  44. package/dist/esm/parser/codex-parser.js +144 -0
  45. package/dist/esm/parser/codex-parser.js.map +7 -0
  46. package/dist/esm/parser/index.js +8 -0
  47. package/dist/esm/parser/index.js.map +7 -0
  48. package/dist/esm/parser/iterators.js +152 -0
  49. package/dist/esm/parser/iterators.js.map +7 -0
  50. package/dist/esm/parser/types.js +2 -0
  51. package/dist/esm/parser/types.js.map +7 -0
  52. package/dist/esm/parser/usfm-parser.js +749 -0
  53. package/dist/esm/parser/usfm-parser.js.map +7 -0
  54. package/dist/esm/parser/usx-parser.js +447 -0
  55. package/dist/esm/parser/usx-parser.js.map +7 -0
  56. package/dist/esm/utils.js +51 -0
  57. package/dist/esm/utils.js.map +7 -0
  58. package/{generation → dist/types/generation}/api.d.ts +46 -5
  59. package/{generation → dist/types/generation}/audio.d.ts +1 -1
  60. package/{generation → dist/types/generation}/dataset.d.ts +1 -1
  61. package/dist/types/generation/index.d.ts +7 -0
  62. package/dist/types/index.d.ts +5 -0
  63. package/{parser → dist/types/parser}/codex-parser.d.ts +1 -1
  64. package/dist/types/parser/index.d.ts +7 -0
  65. package/{parser → dist/types/parser}/usfm-parser.d.ts +1 -1
  66. package/{parser → dist/types/parser}/usx-parser.d.ts +2 -2
  67. package/package.json +25 -4
  68. package/generation/api.js +0 -153
  69. package/generation/api.spec.d.ts +0 -2
  70. package/generation/api.spec.js +0 -463
  71. package/generation/audio.js +0 -60
  72. package/generation/audio.spec.d.ts +0 -2
  73. package/generation/audio.spec.js +0 -36
  74. package/generation/book-order.js +0 -494
  75. package/generation/book-order.spec.d.ts +0 -2
  76. package/generation/book-order.spec.js +0 -8
  77. package/generation/common-types.js +0 -2
  78. package/generation/dataset.js +0 -106
  79. package/generation/index.d.ts +0 -7
  80. package/generation/index.js +0 -38
  81. package/index.d.ts +0 -5
  82. package/index.js +0 -32
  83. package/parser/codex-parser.js +0 -160
  84. package/parser/codex-parser.spec.d.ts +0 -2
  85. package/parser/codex-parser.spec.js +0 -645
  86. package/parser/index.d.ts +0 -7
  87. package/parser/index.js +0 -35
  88. package/parser/iterators.js +0 -222
  89. package/parser/iterators.spec.d.ts +0 -2
  90. package/parser/iterators.spec.js +0 -174
  91. package/parser/types.js +0 -2
  92. package/parser/usfm-parser.js +0 -840
  93. package/parser/usfm-parser.spec.d.ts +0 -2
  94. package/parser/usfm-parser.spec.js +0 -1593
  95. package/parser/usx-parser.js +0 -425
  96. package/parser/usx-parser.spec.d.ts +0 -2
  97. package/parser/usx-parser.spec.js +0 -1260
  98. package/utils.js +0 -73
  99. package/utils.spec.d.ts +0 -2
  100. package/utils.spec.js +0 -42
  101. /package/{generation → dist/types/generation}/book-order.d.ts +0 -0
  102. /package/{generation → dist/types/generation}/common-types.d.ts +0 -0
  103. /package/{parser → dist/types/parser}/iterators.d.ts +0 -0
  104. /package/{parser → dist/types/parser}/types.d.ts +0 -0
  105. /package/{utils.d.ts → dist/types/utils.d.ts} +0 -0
@@ -1,463 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const api_1 = require("./api");
7
- const _01GENBSB_usfm_1 = __importDefault(require("../../../bible/bsb/01GENBSB.usfm"));
8
- const _02EXOBSB_usfm_1 = __importDefault(require("../../../bible/bsb/02EXOBSB.usfm"));
9
- const _131CHBSB_usfm_1 = __importDefault(require("../../../bible/bsb/131CHBSB.usfm"));
10
- const dataset_1 = require("./dataset");
11
- const linkedom_1 = require("linkedom");
12
- describe('replaceSpacesWithUnderscores()', () => {
13
- const cases = [
14
- ['Hello World', 'Hello_World'],
15
- ['Hello World 2', 'Hello_World_2'],
16
- ];
17
- it.each(cases)('should replace spaces with underscores', (input, expected) => {
18
- expect((0, api_1.replaceSpacesWithUnderscores)(input)).toBe(expected);
19
- });
20
- });
21
- describe('generateApiForDataset()', () => {
22
- it('should output a file tree', () => {
23
- let translation1 = {
24
- id: 'bsb',
25
- name: 'Berean Standard Bible',
26
- englishName: 'Berean Standard Bible',
27
- shortName: 'BSB',
28
- language: 'eng',
29
- direction: 'ltr',
30
- licenseUrl: 'https://berean.bible/terms.htm',
31
- website: 'https://berean.bible'
32
- };
33
- let inputFiles = [
34
- {
35
- fileType: 'usfm',
36
- metadata: {
37
- translation: translation1
38
- },
39
- content: firstXLines(_01GENBSB_usfm_1.default, 13)
40
- },
41
- {
42
- fileType: 'usfm',
43
- metadata: {
44
- translation: translation1
45
- },
46
- content: firstXLines(_02EXOBSB_usfm_1.default, 14)
47
- }
48
- ];
49
- const dataset = (0, dataset_1.generateDataset)(inputFiles, new linkedom_1.DOMParser());
50
- const generated = (0, api_1.generateApiForDataset)(dataset);
51
- const files = (0, api_1.generateFilesForApi)(generated);
52
- const tree = fileTree(files);
53
- const expectedTranslation = {
54
- id: 'bsb',
55
- name: 'Berean Standard Bible',
56
- englishName: 'Berean Standard Bible',
57
- shortName: 'BSB',
58
- language: 'eng',
59
- textDirection: 'ltr',
60
- licenseUrl: 'https://berean.bible/terms.htm',
61
- website: 'https://berean.bible',
62
- availableFormats: [
63
- 'json'
64
- ],
65
- listOfBooksApiLink: '/api/bsb/books.json',
66
- numberOfBooks: 2,
67
- totalNumberOfChapters: 2,
68
- totalNumberOfVerses: 4,
69
- languageName: 'English',
70
- languageEnglishName: 'English',
71
- };
72
- expect(tree).toEqual({
73
- '/api/available_translations.json': {
74
- translations: [
75
- expectedTranslation
76
- ]
77
- },
78
- '/api/bsb/books.json': {
79
- translation: expectedTranslation,
80
- books: [
81
- {
82
- id: 'GEN',
83
- name: 'Genesis',
84
- commonName: 'Genesis',
85
- title: 'Genesis',
86
- order: 1,
87
- numberOfChapters: 1,
88
- totalNumberOfVerses: 2,
89
- firstChapterApiLink: '/api/bsb/GEN/1.json',
90
- lastChapterApiLink: '/api/bsb/GEN/1.json',
91
- },
92
- {
93
- id: 'EXO',
94
- name: 'Exodus',
95
- commonName: 'Exodus',
96
- title: 'Exodus',
97
- order: 2,
98
- numberOfChapters: 1,
99
- totalNumberOfVerses: 2,
100
- firstChapterApiLink: '/api/bsb/EXO/1.json',
101
- lastChapterApiLink: '/api/bsb/EXO/1.json',
102
- }
103
- ]
104
- },
105
- '/api/bsb/GEN/1.json': {
106
- translation: expectedTranslation,
107
- book: {
108
- id: 'GEN',
109
- name: 'Genesis',
110
- commonName: 'Genesis',
111
- title: 'Genesis',
112
- order: 1,
113
- numberOfChapters: 1,
114
- totalNumberOfVerses: 2,
115
- firstChapterApiLink: '/api/bsb/GEN/1.json',
116
- lastChapterApiLink: '/api/bsb/GEN/1.json'
117
- },
118
- thisChapterLink: '/api/bsb/GEN/1.json',
119
- thisChapterAudioLinks: {},
120
- nextChapterApiLink: '/api/bsb/EXO/1.json',
121
- nextChapterAudioLinks: {},
122
- previousChapterApiLink: null,
123
- previousChapterAudioLinks: null,
124
- numberOfVerses: 2,
125
- chapter: {
126
- number: 1,
127
- content: [
128
- {
129
- type: 'heading',
130
- content: [
131
- 'The Creation'
132
- ]
133
- },
134
- {
135
- type: 'line_break'
136
- },
137
- {
138
- type: 'verse',
139
- number: 1,
140
- content: [
141
- 'In the beginning God created the heavens and the earth.'
142
- ],
143
- },
144
- {
145
- type: 'line_break'
146
- },
147
- {
148
- type: 'verse',
149
- number: 2,
150
- content: [
151
- 'Now the earth was formless and void, and darkness was over the surface of the deep. And the Spirit of God was hovering over the surface of the waters.'
152
- ],
153
- },
154
- ],
155
- footnotes: []
156
- }
157
- },
158
- '/api/bsb/EXO/1.json': {
159
- translation: expectedTranslation,
160
- book: {
161
- id: 'EXO',
162
- name: 'Exodus',
163
- commonName: 'Exodus',
164
- title: 'Exodus',
165
- order: 2,
166
- numberOfChapters: 1,
167
- totalNumberOfVerses: 2,
168
- firstChapterApiLink: '/api/bsb/EXO/1.json',
169
- lastChapterApiLink: '/api/bsb/EXO/1.json'
170
- },
171
- thisChapterLink: '/api/bsb/EXO/1.json',
172
- thisChapterAudioLinks: {},
173
- nextChapterApiLink: null,
174
- nextChapterAudioLinks: null,
175
- previousChapterApiLink: '/api/bsb/GEN/1.json',
176
- previousChapterAudioLinks: {},
177
- numberOfVerses: 2,
178
- chapter: {
179
- number: 1,
180
- content: [
181
- {
182
- type: 'heading',
183
- content: [
184
- 'The Israelites Multiply in Egypt'
185
- ]
186
- },
187
- {
188
- type: 'line_break'
189
- },
190
- {
191
- type: 'verse',
192
- number: 1,
193
- content: [
194
- 'These are the names of the sons of Israel who went to Egypt with Jacob, each with his family:'
195
- ],
196
- },
197
- {
198
- type: 'line_break'
199
- },
200
- {
201
- type: 'verse',
202
- number: 2,
203
- content: [
204
- 'Reuben, Simeon, Levi, and Judah;'
205
- ],
206
- },
207
- ],
208
- footnotes: []
209
- }
210
- }
211
- });
212
- // expect(availableTranslations).toEqual({
213
- // translations: [
214
- // expectedTranslation
215
- // ]
216
- // });
217
- });
218
- it('should use underscores for spaces in the book name', () => {
219
- let translation1 = {
220
- id: 'bsb',
221
- name: 'Berean Standard Bible',
222
- englishName: 'Berean Standard Bible',
223
- shortName: 'BSB',
224
- language: 'eng',
225
- direction: 'ltr',
226
- licenseUrl: 'https://berean.bible/terms.htm',
227
- website: 'https://berean.bible'
228
- };
229
- let inputFiles = [
230
- {
231
- fileType: 'usfm',
232
- metadata: {
233
- translation: translation1
234
- },
235
- content: firstXLines(_131CHBSB_usfm_1.default, 11)
236
- },
237
- ];
238
- const dataset = (0, dataset_1.generateDataset)(inputFiles, new linkedom_1.DOMParser());
239
- const generated = (0, api_1.generateApiForDataset)(dataset, {
240
- useCommonName: true,
241
- });
242
- const files = (0, api_1.generateFilesForApi)(generated);
243
- const tree = fileTree(files);
244
- const expectedTranslation = {
245
- id: 'bsb',
246
- name: 'Berean Standard Bible',
247
- englishName: 'Berean Standard Bible',
248
- shortName: 'BSB',
249
- language: 'eng',
250
- textDirection: 'ltr',
251
- licenseUrl: 'https://berean.bible/terms.htm',
252
- website: 'https://berean.bible',
253
- availableFormats: [
254
- 'json'
255
- ],
256
- listOfBooksApiLink: '/api/bsb/books.json',
257
- numberOfBooks: 1,
258
- totalNumberOfChapters: 1,
259
- totalNumberOfVerses: 1,
260
- languageName: 'English',
261
- languageEnglishName: 'English',
262
- };
263
- expect(tree).toEqual({
264
- '/api/available_translations.json': {
265
- translations: [
266
- expectedTranslation
267
- ]
268
- },
269
- '/api/bsb/books.json': {
270
- translation: expectedTranslation,
271
- books: [
272
- {
273
- id: '1CH',
274
- name: '1 Chronicles',
275
- commonName: '1 Chronicles',
276
- title: '1 Chronicles',
277
- numberOfChapters: 1,
278
- totalNumberOfVerses: 1,
279
- order: 13,
280
- firstChapterApiLink: '/api/bsb/1_Chronicles/1.json',
281
- lastChapterApiLink: '/api/bsb/1_Chronicles/1.json',
282
- },
283
- ]
284
- },
285
- '/api/bsb/1_Chronicles/1.json': {
286
- translation: expectedTranslation,
287
- book: {
288
- id: '1CH',
289
- name: '1 Chronicles',
290
- commonName: '1 Chronicles',
291
- title: '1 Chronicles',
292
- numberOfChapters: 1,
293
- totalNumberOfVerses: 1,
294
- order: 13,
295
- firstChapterApiLink: '/api/bsb/1_Chronicles/1.json',
296
- lastChapterApiLink: '/api/bsb/1_Chronicles/1.json'
297
- },
298
- thisChapterLink: "/api/bsb/1_Chronicles/1.json",
299
- thisChapterAudioLinks: {},
300
- nextChapterApiLink: null,
301
- nextChapterAudioLinks: null,
302
- previousChapterApiLink: null,
303
- previousChapterAudioLinks: null,
304
- numberOfVerses: 1,
305
- chapter: {
306
- number: 1,
307
- content: [
308
- {
309
- type: 'heading',
310
- content: [
311
- 'From Adam to Abraham'
312
- ]
313
- },
314
- {
315
- type: 'line_break'
316
- },
317
- {
318
- type: 'verse',
319
- number: 1,
320
- content: [
321
- 'Adam, Seth, Enosh,'
322
- ],
323
- },
324
- ],
325
- footnotes: []
326
- }
327
- },
328
- });
329
- // expect(availableTranslations).toEqual({
330
- // translations: [
331
- // expectedTranslation
332
- // ]
333
- // });
334
- });
335
- it('produce the correct names for languages', () => {
336
- let translation1 = {
337
- id: 'bsb',
338
- name: 'Berean Standard Bible',
339
- englishName: 'Berean Standard Bible',
340
- shortName: 'BSB',
341
- language: 'spa',
342
- direction: 'ltr',
343
- licenseUrl: 'https://berean.bible/terms.htm',
344
- website: 'https://berean.bible'
345
- };
346
- let inputFiles = [
347
- {
348
- fileType: 'usfm',
349
- metadata: {
350
- translation: translation1
351
- },
352
- content: firstXLines(_131CHBSB_usfm_1.default, 11)
353
- },
354
- ];
355
- const dataset = (0, dataset_1.generateDataset)(inputFiles, new linkedom_1.DOMParser());
356
- const generated = (0, api_1.generateApiForDataset)(dataset, {
357
- useCommonName: true,
358
- });
359
- const files = (0, api_1.generateFilesForApi)(generated);
360
- const tree = fileTree(files);
361
- const expectedTranslation = {
362
- id: 'bsb',
363
- name: 'Berean Standard Bible',
364
- englishName: 'Berean Standard Bible',
365
- shortName: 'BSB',
366
- language: 'spa',
367
- textDirection: 'ltr',
368
- licenseUrl: 'https://berean.bible/terms.htm',
369
- website: 'https://berean.bible',
370
- availableFormats: [
371
- 'json'
372
- ],
373
- listOfBooksApiLink: '/api/bsb/books.json',
374
- numberOfBooks: 1,
375
- totalNumberOfChapters: 1,
376
- totalNumberOfVerses: 1,
377
- languageName: 'español',
378
- languageEnglishName: 'Spanish',
379
- };
380
- expect(tree).toEqual({
381
- '/api/available_translations.json': {
382
- translations: [
383
- expectedTranslation
384
- ]
385
- },
386
- '/api/bsb/books.json': {
387
- translation: expectedTranslation,
388
- books: [
389
- {
390
- id: '1CH',
391
- name: '1 Chronicles',
392
- commonName: '1 Chronicles',
393
- title: '1 Chronicles',
394
- numberOfChapters: 1,
395
- totalNumberOfVerses: 1,
396
- order: 13,
397
- firstChapterApiLink: '/api/bsb/1_Chronicles/1.json',
398
- lastChapterApiLink: '/api/bsb/1_Chronicles/1.json',
399
- },
400
- ]
401
- },
402
- '/api/bsb/1_Chronicles/1.json': {
403
- translation: expectedTranslation,
404
- book: {
405
- id: '1CH',
406
- name: '1 Chronicles',
407
- commonName: '1 Chronicles',
408
- title: '1 Chronicles',
409
- numberOfChapters: 1,
410
- totalNumberOfVerses: 1,
411
- order: 13,
412
- firstChapterApiLink: '/api/bsb/1_Chronicles/1.json',
413
- lastChapterApiLink: '/api/bsb/1_Chronicles/1.json'
414
- },
415
- thisChapterLink: "/api/bsb/1_Chronicles/1.json",
416
- thisChapterAudioLinks: {},
417
- nextChapterApiLink: null,
418
- nextChapterAudioLinks: null,
419
- previousChapterApiLink: null,
420
- previousChapterAudioLinks: null,
421
- numberOfVerses: 1,
422
- chapter: {
423
- number: 1,
424
- content: [
425
- {
426
- type: 'heading',
427
- content: [
428
- 'From Adam to Abraham'
429
- ]
430
- },
431
- {
432
- type: 'line_break'
433
- },
434
- {
435
- type: 'verse',
436
- number: 1,
437
- content: [
438
- 'Adam, Seth, Enosh,'
439
- ],
440
- },
441
- ],
442
- footnotes: []
443
- }
444
- },
445
- });
446
- // expect(availableTranslations).toEqual({
447
- // translations: [
448
- // expectedTranslation
449
- // ]
450
- // });
451
- });
452
- });
453
- function firstXLines(content, x) {
454
- const lines = content.split('\n');
455
- return lines.slice(0, x).join('\n');
456
- }
457
- function fileTree(outputFiles) {
458
- let result = {};
459
- for (let file of outputFiles) {
460
- result[file.path] = file.content;
461
- }
462
- return result;
463
- }
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KNOWN_AUDIO_TRANSLATIONS = void 0;
4
- exports.getAudioUrlsForChapter = getAudioUrlsForChapter;
5
- exports.capitalize = capitalize;
6
- const lodash_1 = require("lodash");
7
- const book_order_1 = require("./book-order");
8
- const openBibleUrlGenerator = (translation, reader, postfix) => {
9
- return (bookId, chapter) => {
10
- const bookOrder = (0, lodash_1.padStart)(book_order_1.bookOrderMap.get(bookId).toString(), 2, '0');
11
- const chapterStr = (0, lodash_1.padStart)(chapter.toString(), 3, '0');
12
- let link = `https://openbible.com/audio/${reader}/${translation}_${bookOrder}_${capitalize(bookId)}_${chapterStr}`;
13
- if (postfix) {
14
- link += `_${postfix}`;
15
- }
16
- link += '.mp3';
17
- return link;
18
- };
19
- };
20
- /**
21
- * A map of translation IDs to a map of reader IDs to the URL generator for the audio file.
22
- */
23
- exports.KNOWN_AUDIO_TRANSLATIONS = new Map([
24
- ['BSB', new Map([
25
- ['gilbert', openBibleUrlGenerator('BSB', 'gilbert', 'G')],
26
- ['hays', openBibleUrlGenerator('BSB', 'hays', "H")],
27
- ['souer', openBibleUrlGenerator('BSB', 'souer', null)],
28
- ])],
29
- ]);
30
- /**
31
- * Gets the audio URLs for the given translation, book, and chapter.
32
- * @param translationId The ID of the translation.
33
- * @param bookId The ID of the book.
34
- * @param chapter The number of the chapter.
35
- */
36
- function getAudioUrlsForChapter(translationId, bookId, chapter) {
37
- const translation = exports.KNOWN_AUDIO_TRANSLATIONS.get(translationId);
38
- if (!translation) {
39
- return {};
40
- }
41
- const links = {};
42
- for (let [reader, generator] of translation) {
43
- const url = generator(bookId, chapter);
44
- if (url) {
45
- links[reader] = url;
46
- }
47
- }
48
- return links;
49
- }
50
- /**
51
- * Capitalizes the first letter of the given string.
52
- * @param str The string to capitalize.
53
- */
54
- function capitalize(str) {
55
- const char = str.charAt(0);
56
- if (/[0-9]/.test(char)) {
57
- return str.charAt(0) + str.charAt(1).toUpperCase() + str.slice(2).toLowerCase();
58
- }
59
- return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
60
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=audio.spec.d.ts.map
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const audio_1 = require("./audio");
4
- describe('capitalize()', () => {
5
- const cases = [
6
- ['empty', '', ''],
7
- ['single letter', 'a', 'A'],
8
- ['number', '1abc', '1Abc'],
9
- ['word', 'word', 'Word'],
10
- ['lowercase rest', 'WORD', 'Word'],
11
- ['sentence', 'this is a sentence', 'This is a sentence'],
12
- ];
13
- it.each(cases)('should capitalize %s', (_desc, input, expected) => {
14
- expect((0, audio_1.capitalize)(input)).toBe(expected);
15
- });
16
- });
17
- describe('KNOWN_AUDIO_TRANSLATIONS', () => {
18
- const cases = [
19
- // Gilbert
20
- ['BSB', 'gilbert', 'GEN', 1, 'https://openbible.com/audio/gilbert/BSB_01_Gen_001_G.mp3'],
21
- ['BSB', 'gilbert', '1SA', 5, 'https://openbible.com/audio/gilbert/BSB_09_1Sa_005_G.mp3'],
22
- ['BSB', 'gilbert', 'PSA', 110, 'https://openbible.com/audio/gilbert/BSB_19_Psa_110_G.mp3'],
23
- // Hays
24
- ['BSB', 'hays', 'GEN', 1, 'https://openbible.com/audio/hays/BSB_01_Gen_001_H.mp3'],
25
- ['BSB', 'hays', '1SA', 5, 'https://openbible.com/audio/hays/BSB_09_1Sa_005_H.mp3'],
26
- ['BSB', 'hays', 'PSA', 110, 'https://openbible.com/audio/hays/BSB_19_Psa_110_H.mp3'],
27
- // Souer
28
- ['BSB', 'souer', 'GEN', 1, 'https://openbible.com/audio/souer/BSB_01_Gen_001.mp3'],
29
- ['BSB', 'souer', '1SA', 5, 'https://openbible.com/audio/souer/BSB_09_1Sa_005.mp3'],
30
- ['BSB', 'souer', 'PSA', 110, 'https://openbible.com/audio/souer/BSB_19_Psa_110.mp3'],
31
- ];
32
- it.each(cases)('should generate the correct URL for %s %s %s', (translationId, reader, bookId, chapter, expected) => {
33
- const generator = audio_1.KNOWN_AUDIO_TRANSLATIONS.get(translationId).get(reader);
34
- expect(generator(bookId, chapter)).toBe(expected);
35
- });
36
- });