@internetarchive/radio-player 0.0.3 → 0.1.0
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/package.json +2 -2
- package/.eslintrc +0 -37
- package/.gitignore +0 -11
- package/.storybook/.babelrc +0 -15
- package/.storybook/addons.js +0 -7
- package/.storybook/config.js +0 -11
- package/.storybook/webpack.config.js +0 -5
- package/demo/full-text-search-service.ts +0 -32
- package/demo/index.html +0 -53
- package/demo/radio-player-controller.ts +0 -237
- package/karma.bs.config.js +0 -16
- package/karma.conf.js +0 -66
- package/package-lock.json +0 -51719
- package/stories/index.stories.js +0 -40
- package/stories/transcript.js +0 -683
- package/test/assets/arrow.mp3 +0 -0
- package/test/music-zone.test.js +0 -13
- package/test/promised-sleep.js +0 -3
- package/test/radio-player-config.test.js +0 -42
- package/test/radio-player.test.js +0 -1072
- package/test/sample_transcript.js +0 -1493
- package/test/search-handler/search-backends/full-text-sample-response-brackets.js +0 -60
- package/test/search-handler/search-backends/full-text-sample-response-em.js +0 -60
- package/test/search-handler/search-backends/full-text-search-backend.test.js +0 -74
- package/test/search-handler/search-backends/full-text-search-response.test.js +0 -14
- package/test/search-handler/search-backends/local-search-backend.test.js +0 -39
- package/test/search-handler/search-handler.test.js +0 -550
- package/test/search-handler/search-helper.test.js +0 -63
- package/test/search-handler/search-model.test.js +0 -56
- package/test/search-handler/transcript-index.test.js +0 -66
- package/test/search-results-switcher.test.js +0 -97
- package/tsconfig.build.json +0 -7
- package/tsconfig.json +0 -21
- package/yarn.lock +0 -14450
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
html, fixture, expect, oneEvent, elementUpdated
|
|
3
|
-
} from '@open-wc/testing';
|
|
4
|
-
|
|
5
|
-
import { TranscriptConfig, TranscriptEntryConfig } from '@internetarchive/transcript-view';
|
|
6
|
-
import { TranscriptIndex } from '../../lib/src/search-handler/transcript-index';
|
|
7
|
-
|
|
8
|
-
describe('Transcript Index', () => {
|
|
9
|
-
it('correctly calculates entry start and end index offsets of the source transcript', async () => {
|
|
10
|
-
const entry1 = new TranscriptEntryConfig(1, 0, 4, 'foo bar baz', false);
|
|
11
|
-
const entry2 = new TranscriptEntryConfig(2, 5, 9, 'boop blop', false);
|
|
12
|
-
const entry3 = new TranscriptEntryConfig(3, 10, 13, 'bang boing', false);
|
|
13
|
-
const transcriptConfig = new TranscriptConfig([entry1, entry2, entry3]);
|
|
14
|
-
const transcriptIndex = new TranscriptIndex(transcriptConfig);
|
|
15
|
-
|
|
16
|
-
const entryStartEndIndices = transcriptIndex.transcriptEntryRanges;
|
|
17
|
-
|
|
18
|
-
// note a space is added between each transcript entry so it increases each
|
|
19
|
-
// subsequent index by 1
|
|
20
|
-
expect(entryStartEndIndices[0].entry).to.equal(entry1);
|
|
21
|
-
expect(entryStartEndIndices[0].range.startIndex).to.equal(0);
|
|
22
|
-
expect(entryStartEndIndices[0].range.endIndex).to.equal(11);
|
|
23
|
-
|
|
24
|
-
expect(entryStartEndIndices[1].entry).to.equal(entry2);
|
|
25
|
-
expect(entryStartEndIndices[1].range.startIndex).to.equal(12);
|
|
26
|
-
expect(entryStartEndIndices[1].range.endIndex).to.equal(21);
|
|
27
|
-
|
|
28
|
-
expect(entryStartEndIndices[2].entry).to.equal(entry3);
|
|
29
|
-
expect(entryStartEndIndices[2].range.startIndex).to.equal(22);
|
|
30
|
-
expect(entryStartEndIndices[2].range.endIndex).to.equal(32);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('correctly builds the full text blob', async () => {
|
|
34
|
-
const entry1 = new TranscriptEntryConfig(1, 0, 4, 'foo bar baz', false);
|
|
35
|
-
const entry2 = new TranscriptEntryConfig(2, 5, 9, 'boop blop', false);
|
|
36
|
-
const entry3 = new TranscriptEntryConfig(3, 10, 13, 'bang boing', false);
|
|
37
|
-
const transcriptConfig = new TranscriptConfig([entry1, entry2, entry3]);
|
|
38
|
-
const transcriptIndex = new TranscriptIndex(transcriptConfig);
|
|
39
|
-
|
|
40
|
-
expect(transcriptIndex.mergedTranscript).to.equal('foo bar baz boop blop bang boing');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('correctly finds the correct entry range for a given index', async () => {
|
|
44
|
-
const entry1 = new TranscriptEntryConfig(1, 0, 4, 'foo bar baz', false);
|
|
45
|
-
const entry2 = new TranscriptEntryConfig(2, 5, 9, 'boop blop', false);
|
|
46
|
-
const entry3 = new TranscriptEntryConfig(3, 10, 13, 'bump baz boing', false);
|
|
47
|
-
const transcriptConfig = new TranscriptConfig([entry1, entry2, entry3]);
|
|
48
|
-
const transcriptIndex = new TranscriptIndex(transcriptConfig);
|
|
49
|
-
|
|
50
|
-
// in second entry
|
|
51
|
-
const transcriptEntryRange = transcriptIndex.getTranscriptEntryAt(14);
|
|
52
|
-
expect(transcriptEntryRange.entry).to.equal(entry2);
|
|
53
|
-
|
|
54
|
-
// in third entry
|
|
55
|
-
const transcriptEntryRange2 = transcriptIndex.getTranscriptEntryAt(23);
|
|
56
|
-
expect(transcriptEntryRange2.entry).to.equal(entry3);
|
|
57
|
-
|
|
58
|
-
// in-between the first and second entry
|
|
59
|
-
const transcriptEntryRange3 = transcriptIndex.getTranscriptEntryAt(11);
|
|
60
|
-
expect(transcriptEntryRange3).to.equal(undefined);
|
|
61
|
-
|
|
62
|
-
// outside of range
|
|
63
|
-
const transcriptEntryRange4 = transcriptIndex.getTranscriptEntryAt(45);
|
|
64
|
-
expect(transcriptEntryRange4).to.equal(undefined);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
html, fixture, expect, oneEvent, elementUpdated
|
|
3
|
-
} from '@open-wc/testing';
|
|
4
|
-
|
|
5
|
-
import promisedSleep from './promised-sleep';
|
|
6
|
-
|
|
7
|
-
import '../lib/src/radio-player';
|
|
8
|
-
|
|
9
|
-
describe('Search Results Switcher', () => {
|
|
10
|
-
it('defaults to 0 results', async () => {
|
|
11
|
-
const el = await fixture(html`
|
|
12
|
-
<search-results-switcher></search-results-switcher>
|
|
13
|
-
`);
|
|
14
|
-
|
|
15
|
-
expect(el.numberOfResults).to.equal(0);
|
|
16
|
-
expect(el.currentResultIndex).to.equal(0);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('renders the number of results correctly', async () => {
|
|
20
|
-
const el = await fixture(html`
|
|
21
|
-
<search-results-switcher numberOfResults='7'></search-results-switcher>
|
|
22
|
-
`);
|
|
23
|
-
|
|
24
|
-
const { shadowRoot } = el;
|
|
25
|
-
|
|
26
|
-
expect(shadowRoot.getElementById('current-result').innerText).to.equal('1');
|
|
27
|
-
expect(shadowRoot.getElementById('number-of-results').innerText).to.equal('7');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('increments the values properly and emits event when changed', async () => {
|
|
31
|
-
const el = await fixture(html`
|
|
32
|
-
<search-results-switcher numberOfResults='7'></search-results-switcher>
|
|
33
|
-
`);
|
|
34
|
-
|
|
35
|
-
const { shadowRoot } = el;
|
|
36
|
-
|
|
37
|
-
const clickEvent = new MouseEvent('click');
|
|
38
|
-
const nextButton = shadowRoot.getElementById('next-button');
|
|
39
|
-
|
|
40
|
-
setTimeout(() => { nextButton.dispatchEvent(clickEvent); });
|
|
41
|
-
const response = await oneEvent(el, 'searchResultIndexChanged');
|
|
42
|
-
expect(response.detail.searchResultIndex).to.equal(1);
|
|
43
|
-
expect(el.currentResultIndex).to.equal(1);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('wraps around to the beginning if it reaches the end', async () => {
|
|
47
|
-
const el = await fixture(html`
|
|
48
|
-
<search-results-switcher numberOfResults='7'></search-results-switcher>
|
|
49
|
-
`);
|
|
50
|
-
|
|
51
|
-
el.currentResultIndex = 6;
|
|
52
|
-
|
|
53
|
-
const { shadowRoot } = el;
|
|
54
|
-
|
|
55
|
-
const clickEvent = new MouseEvent('click');
|
|
56
|
-
const nextButton = shadowRoot.getElementById('next-button');
|
|
57
|
-
|
|
58
|
-
setTimeout(() => { nextButton.dispatchEvent(clickEvent); });
|
|
59
|
-
const response = await oneEvent(el, 'searchResultIndexChanged');
|
|
60
|
-
expect(response.detail.searchResultIndex).to.equal(0);
|
|
61
|
-
expect(el.currentResultIndex).to.equal(0);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('decrements the values properly and emits event when changed', async () => {
|
|
65
|
-
const el = await fixture(html`
|
|
66
|
-
<search-results-switcher numberOfResults='7'></search-results-switcher>
|
|
67
|
-
`);
|
|
68
|
-
|
|
69
|
-
el.currentResultIndex = 4;
|
|
70
|
-
|
|
71
|
-
const { shadowRoot } = el;
|
|
72
|
-
|
|
73
|
-
const clickEvent = new MouseEvent('click');
|
|
74
|
-
const nextButton = shadowRoot.getElementById('previous-button');
|
|
75
|
-
|
|
76
|
-
setTimeout(() => { nextButton.dispatchEvent(clickEvent); });
|
|
77
|
-
const response = await oneEvent(el, 'searchResultIndexChanged');
|
|
78
|
-
expect(response.detail.searchResultIndex).to.equal(3);
|
|
79
|
-
expect(el.currentResultIndex).to.equal(3);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('wraps around to the end if it reaches the beginning', async () => {
|
|
83
|
-
const el = await fixture(html`
|
|
84
|
-
<search-results-switcher numberOfResults='7'></search-results-switcher>
|
|
85
|
-
`);
|
|
86
|
-
|
|
87
|
-
const { shadowRoot } = el;
|
|
88
|
-
|
|
89
|
-
const clickEvent = new MouseEvent('click');
|
|
90
|
-
const nextButton = shadowRoot.getElementById('previous-button');
|
|
91
|
-
|
|
92
|
-
setTimeout(() => { nextButton.dispatchEvent(clickEvent); });
|
|
93
|
-
const response = await oneEvent(el, 'searchResultIndexChanged');
|
|
94
|
-
expect(response.detail.searchResultIndex).to.equal(6);
|
|
95
|
-
expect(el.currentResultIndex).to.equal(6);
|
|
96
|
-
});
|
|
97
|
-
});
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es6", // define the target version of js
|
|
4
|
-
"lib": ["es2016", "dom"], // define the minimum set of libraries needed to build
|
|
5
|
-
"experimentalDecorators": true, // needed for using decorators
|
|
6
|
-
"moduleResolution": "node", // needed to correctly resolve node_modules like `lit-element`
|
|
7
|
-
"sourceMap": true,
|
|
8
|
-
"outDir": "./lib",
|
|
9
|
-
"declaration": true,
|
|
10
|
-
"strict": true
|
|
11
|
-
},
|
|
12
|
-
"include": [
|
|
13
|
-
"src/**/*.ts",
|
|
14
|
-
"dev_tools/**/*.ts",
|
|
15
|
-
"demo/**/*.ts"
|
|
16
|
-
],
|
|
17
|
-
"exclude": [
|
|
18
|
-
"node_modules/!(@open-wc)",
|
|
19
|
-
"node_modules/!(@types)"
|
|
20
|
-
]
|
|
21
|
-
}
|