rx-player 4.5.0-dev.2026031700 → 4.5.0-dev.2026033100
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/CHANGELOG.md +3 -1
- package/VERSION +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
- package/dist/commonjs/compat/browser_compatibility_types.d.ts +16 -14
- package/dist/commonjs/compat/browser_compatibility_types.d.ts.map +1 -1
- package/dist/commonjs/compat/browser_compatibility_types.js +7 -4
- package/dist/commonjs/compat/browser_version.d.ts +2 -1
- package/dist/commonjs/compat/browser_version.d.ts.map +1 -1
- package/dist/commonjs/compat/browser_version.js +13 -0
- package/dist/commonjs/compat/disable_remote_playback_on_managed_media_source.d.ts.map +1 -1
- package/dist/commonjs/compat/disable_remote_playback_on_managed_media_source.js +1 -1
- package/dist/commonjs/compat/is_codec_supported.d.ts.map +1 -1
- package/dist/commonjs/compat/is_codec_supported.js +4 -3
- package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts +26 -0
- package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts.map +1 -0
- package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.js +45 -0
- package/dist/commonjs/core/entry/utils.js +3 -3
- package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
- package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +2 -1
- package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts.map +1 -1
- package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +2 -1
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.d.ts.map +1 -1
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +8 -6
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +4 -3
- package/dist/commonjs/initialize_worker.js +1 -1
- package/dist/commonjs/main_thread/api/debug/modules/segment_buffer_content.js +3 -3
- package/dist/commonjs/main_thread/api/public_api.js +2 -2
- package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
- package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.js +24 -12
- package/dist/commonjs/manifest/classes/adaptation.d.ts.map +1 -1
- package/dist/commonjs/manifest/classes/adaptation.js +3 -1
- package/dist/commonjs/manifest/classes/representation.d.ts +6 -2
- package/dist/commonjs/manifest/classes/representation.d.ts.map +1 -1
- package/dist/commonjs/manifest/classes/representation.js +45 -23
- package/dist/commonjs/manifest/types.d.ts +14 -6
- package/dist/commonjs/manifest/types.d.ts.map +1 -1
- package/dist/commonjs/manifest/utils.js +4 -4
- package/dist/commonjs/mse/main_media_source_interface.d.ts.map +1 -1
- package/dist/commonjs/mse/main_media_source_interface.js +3 -2
- package/dist/commonjs/mse/worker_media_source_interface.d.ts.map +1 -1
- package/dist/commonjs/parsers/containers/isobmff/get_box.d.ts +12 -1
- package/dist/commonjs/parsers/containers/isobmff/get_box.d.ts.map +1 -1
- package/dist/commonjs/parsers/containers/isobmff/get_box.js +16 -0
- package/dist/commonjs/parsers/containers/isobmff/index.d.ts +2 -1
- package/dist/commonjs/parsers/containers/isobmff/index.d.ts.map +1 -1
- package/dist/commonjs/parsers/containers/isobmff/index.js +3 -1
- package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts +13 -0
- package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts.map +1 -0
- package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.js +180 -0
- package/dist/commonjs/parsers/manifest/metaplaylist/metaplaylist_parser.js +4 -4
- package/dist/commonjs/transports/dash/segment_parser.d.ts.map +1 -1
- package/dist/commonjs/transports/dash/segment_parser.js +6 -0
- package/dist/commonjs/transports/dash/text_parser.d.ts.map +1 -1
- package/dist/commonjs/transports/dash/text_parser.js +5 -1
- package/dist/commonjs/transports/local/text_parser.d.ts.map +1 -1
- package/dist/commonjs/transports/local/text_parser.js +5 -1
- package/dist/commonjs/transports/metaplaylist/pipelines.d.ts.map +1 -1
- package/dist/commonjs/transports/metaplaylist/pipelines.js +2 -1
- package/dist/commonjs/transports/smooth/pipelines.js +3 -3
- package/dist/commonjs/transports/types.d.ts +28 -2
- package/dist/commonjs/transports/types.d.ts.map +1 -1
- package/dist/commonjs/transports/utils/parse_text_track.d.ts +9 -2
- package/dist/commonjs/transports/utils/parse_text_track.d.ts.map +1 -1
- package/dist/commonjs/transports/utils/parse_text_track.js +1 -1
- package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
- package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
- package/dist/es2017/compat/browser_compatibility_types.d.ts +16 -14
- package/dist/es2017/compat/browser_compatibility_types.d.ts.map +1 -1
- package/dist/es2017/compat/browser_compatibility_types.js +7 -1
- package/dist/es2017/compat/browser_version.d.ts +2 -1
- package/dist/es2017/compat/browser_version.d.ts.map +1 -1
- package/dist/es2017/compat/browser_version.js +13 -1
- package/dist/es2017/compat/disable_remote_playback_on_managed_media_source.d.ts.map +1 -1
- package/dist/es2017/compat/disable_remote_playback_on_managed_media_source.js +2 -2
- package/dist/es2017/compat/is_codec_supported.d.ts.map +1 -1
- package/dist/es2017/compat/is_codec_supported.js +2 -1
- package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts +26 -0
- package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts.map +1 -0
- package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.js +42 -0
- package/dist/es2017/core/entry/utils.js +4 -4
- package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
- package/dist/es2017/core/fetchers/segment/segment_fetcher.js +2 -1
- package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts.map +1 -1
- package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +2 -1
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.d.ts.map +1 -1
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +3 -1
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +2 -1
- package/dist/es2017/initialize_worker.js +1 -1
- package/dist/es2017/main_thread/api/debug/modules/segment_buffer_content.js +3 -3
- package/dist/es2017/main_thread/api/public_api.js +2 -2
- package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
- package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.js +9 -7
- package/dist/es2017/manifest/classes/adaptation.d.ts.map +1 -1
- package/dist/es2017/manifest/classes/adaptation.js +3 -1
- package/dist/es2017/manifest/classes/representation.d.ts +6 -2
- package/dist/es2017/manifest/classes/representation.d.ts.map +1 -1
- package/dist/es2017/manifest/classes/representation.js +45 -23
- package/dist/es2017/manifest/types.d.ts +14 -6
- package/dist/es2017/manifest/types.d.ts.map +1 -1
- package/dist/es2017/manifest/utils.js +4 -4
- package/dist/es2017/mse/main_media_source_interface.d.ts.map +1 -1
- package/dist/es2017/mse/main_media_source_interface.js +2 -1
- package/dist/es2017/mse/worker_media_source_interface.d.ts.map +1 -1
- package/dist/es2017/parsers/containers/isobmff/get_box.d.ts +12 -1
- package/dist/es2017/parsers/containers/isobmff/get_box.d.ts.map +1 -1
- package/dist/es2017/parsers/containers/isobmff/get_box.js +16 -1
- package/dist/es2017/parsers/containers/isobmff/index.d.ts +2 -1
- package/dist/es2017/parsers/containers/isobmff/index.d.ts.map +1 -1
- package/dist/es2017/parsers/containers/isobmff/index.js +2 -1
- package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts +13 -0
- package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts.map +1 -0
- package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.js +155 -0
- package/dist/es2017/parsers/manifest/metaplaylist/metaplaylist_parser.js +4 -4
- package/dist/es2017/transports/dash/segment_parser.d.ts.map +1 -1
- package/dist/es2017/transports/dash/segment_parser.js +7 -1
- package/dist/es2017/transports/dash/text_parser.d.ts.map +1 -1
- package/dist/es2017/transports/dash/text_parser.js +5 -1
- package/dist/es2017/transports/local/text_parser.d.ts.map +1 -1
- package/dist/es2017/transports/local/text_parser.js +5 -1
- package/dist/es2017/transports/metaplaylist/pipelines.d.ts.map +1 -1
- package/dist/es2017/transports/metaplaylist/pipelines.js +2 -1
- package/dist/es2017/transports/smooth/pipelines.js +3 -3
- package/dist/es2017/transports/types.d.ts +28 -2
- package/dist/es2017/transports/types.d.ts.map +1 -1
- package/dist/es2017/transports/utils/parse_text_track.d.ts +9 -2
- package/dist/es2017/transports/utils/parse_text_track.d.ts.map +1 -1
- package/dist/es2017/transports/utils/parse_text_track.js +1 -1
- package/dist/worker.js +6 -6
- package/eslint.config.mjs +1 -14
- package/package.json +1 -1
- package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
- package/src/compat/__tests__/browser_compatibility_types.test.ts +15 -26
- package/src/compat/__tests__/browser_version.test.ts +57 -18
- package/src/compat/__tests__/clear_element_src.test.ts +20 -40
- package/src/compat/__tests__/is_codec_supported.test.ts +39 -44
- package/src/compat/__tests__/is_vtt_cue.test.ts +5 -8
- package/src/compat/__tests__/make_vtt_cue.test.ts +20 -31
- package/src/compat/__tests__/remove_cue.test.ts +8 -20
- package/src/compat/__tests__/should_patch_out_dolby_vision_config_data_from_mp4.test.ts +78 -0
- package/src/compat/browser_compatibility_types.ts +8 -1
- package/src/compat/browser_version.ts +17 -1
- package/src/compat/disable_remote_playback_on_managed_media_source.ts +2 -2
- package/src/compat/is_codec_supported.ts +2 -1
- package/src/compat/should_patch_out_dolby_vision_config_data_from_mp4.ts +50 -0
- package/src/core/adaptive/__tests__/adaptive_representation_selector.test.ts +68 -28
- package/src/core/adaptive/__tests__/buffer_based_chooser.test.ts +26 -84
- package/src/core/entry/__tests__/utils.test.ts +7 -1
- package/src/core/entry/utils.ts +4 -4
- package/src/core/fetchers/segment/segment_fetcher.ts +2 -1
- package/src/errors/__tests__/format_error.test.ts +23 -24
- package/src/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.ts +2 -1
- package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/mediaDisplayInfos.test.ts +106 -0
- package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/HDCPPolicy.test.ts +19 -42
- package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/decodingInfo.test.ts +33 -40
- package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/defaultCodecsFinder.test.ts +44 -68
- package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/mediaContentType.test.ts +45 -80
- package/src/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.ts +3 -1
- package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.ts +2 -1
- package/src/features/__tests__/add_features.test.ts +12 -27
- package/src/initialize_worker.ts +1 -1
- package/src/main_thread/api/__tests__/option_utils.test.ts +38 -67
- package/src/main_thread/api/__tests__/public_api.test.ts +56 -138
- package/src/main_thread/api/debug/modules/segment_buffer_content.ts +3 -3
- package/src/main_thread/api/public_api.ts +2 -2
- package/src/main_thread/decrypt/__tests__/__global__/find_key_system.test.ts +46 -28
- package/src/main_thread/decrypt/__tests__/__global__/get_license.test.ts +40 -10
- package/src/main_thread/decrypt/__tests__/__global__/init_data.test.ts +112 -129
- package/src/main_thread/decrypt/__tests__/__global__/media_key_system_access.test.ts +282 -377
- package/src/main_thread/decrypt/__tests__/__global__/media_keys.test.ts +70 -63
- package/src/main_thread/decrypt/__tests__/__global__/server_certificate.test.ts +73 -54
- package/src/main_thread/decrypt/__tests__/__global__/utils.ts +43 -83
- package/src/main_thread/decrypt/__tests__/find_key_system.test.ts +36 -17
- package/src/main_thread/decrypt/utils/__tests__/clean_old_stored_persistent_info.test.ts +44 -48
- package/src/main_thread/init/utils/__tests__/are_same_stream_events.test.ts +7 -22
- package/src/main_thread/init/utils/__tests__/refresh_scheduled_events_list.test.ts +3 -6
- package/src/main_thread/init/utils/__tests__/update_manifest_codec_support.test.ts +42 -19
- package/src/main_thread/init/utils/update_manifest_codec_support.ts +8 -6
- package/src/manifest/classes/__tests__/adaptation.test.ts +69 -125
- package/src/manifest/classes/__tests__/manifest.test.ts +88 -95
- package/src/manifest/classes/__tests__/period.test.ts +167 -117
- package/src/manifest/classes/__tests__/representation.test.ts +84 -25
- package/src/manifest/classes/__tests__/update_periods.test.ts +96 -225
- package/src/manifest/classes/adaptation.ts +4 -1
- package/src/manifest/classes/representation.ts +59 -27
- package/src/manifest/types.ts +14 -6
- package/src/manifest/utils.ts +4 -4
- package/src/mse/__tests__/main_media_source_interface.test.ts +3 -1
- package/src/mse/__tests__/worker_media_source_interface.test.ts +608 -0
- package/src/mse/main_media_source_interface.ts +2 -1
- package/src/mse/worker_media_source_interface.ts +2 -2
- package/src/parsers/containers/isobmff/__tests__/get_box.test.ts +449 -0
- package/src/parsers/containers/isobmff/__tests__/remove_dolby_vision_config_data.test.ts +282 -0
- package/src/parsers/containers/isobmff/get_box.ts +17 -0
- package/src/parsers/containers/isobmff/index.ts +8 -1
- package/src/parsers/containers/isobmff/remove_dolby_vision_config_data.ts +179 -0
- package/src/parsers/manifest/dash/common/__tests__/get_clock_offset.test.ts +19 -25
- package/src/parsers/manifest/dash/common/__tests__/get_http_utc-timing_url.test.ts +7 -19
- package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/ContentProtection.test.ts +26 -37
- package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/Initialization.test.ts +24 -53
- package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/SegmentURL.test.ts +31 -78
- package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +6 -4
- package/src/parsers/manifest/utils/__tests__/update_segment_timeline.test.ts +79 -87
- package/src/parsers/texttracks/ttml/__tests__/resolve_styles_inheritance.test.ts +20 -26
- package/src/parsers/texttracks/ttml/html/__tests__/__global__/html_ttml_parser.test.ts +2 -7
- package/src/parsers/texttracks/webvtt/__tests__/parse_cue_block.test.ts +33 -30
- package/src/parsers/texttracks/webvtt/__tests__/parse_style_block.test.ts +33 -100
- package/src/parsers/texttracks/webvtt/html/__tests__/convert_payload_to_html.test.ts +16 -18
- package/src/parsers/texttracks/webvtt/html/__tests__/parse_webvtt_to_div.test.ts +73 -78
- package/src/parsers/texttracks/webvtt/html/__tests__/to_html.test.ts +36 -37
- package/src/transports/dash/segment_parser.ts +13 -0
- package/src/transports/dash/text_parser.ts +5 -1
- package/src/transports/local/text_parser.ts +5 -1
- package/src/transports/metaplaylist/pipelines.ts +2 -1
- package/src/transports/smooth/isobmff/__tests__/create_boxes.test.ts +150 -127
- package/src/transports/smooth/pipelines.ts +3 -3
- package/src/transports/types.ts +28 -2
- package/src/transports/utils/__tests__/check_isobmff_integrity.test.ts +49 -75
- package/src/transports/utils/parse_text_track.ts +10 -3
- package/src/utils/__tests__/object_assign.test.ts +2 -2
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import { describe, beforeEach, it, expect, vi } from "vitest";
|
|
2
|
-
import
|
|
1
|
+
import { describe, beforeEach, it, expect, vi, afterEach } from "vitest";
|
|
2
|
+
import parseCueBlock from "../parse_cue_block";
|
|
3
|
+
import type parseTimestamp from "../parse_timestamp";
|
|
4
|
+
|
|
5
|
+
const mocks = vi.hoisted(() => {
|
|
6
|
+
return {
|
|
7
|
+
parseTimestamp: vi.fn(),
|
|
8
|
+
};
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
vi.mock("../parse_timestamp", () => ({
|
|
12
|
+
default: mocks.parseTimestamp,
|
|
13
|
+
}));
|
|
3
14
|
|
|
4
15
|
const cueBlock1 = [
|
|
5
16
|
"112",
|
|
@@ -35,13 +46,17 @@ const notCueBlock6 = ["aa:18:31.080 --> 00:18:32.200", "TOTO", "TATA"];
|
|
|
35
46
|
const notCueBlock7 = ["00:18:31.080 --> bb:18:32.200", "TOTO", "TATA"];
|
|
36
47
|
|
|
37
48
|
describe("parsers - srt - parseCueBlocks", () => {
|
|
38
|
-
beforeEach(() => {
|
|
49
|
+
beforeEach(async () => {
|
|
39
50
|
vi.resetModules();
|
|
51
|
+
const actualParseTimestamp = (await vi.importActual("../parse_timestamp"))
|
|
52
|
+
.default as typeof parseTimestamp;
|
|
53
|
+
mocks.parseTimestamp.mockImplementation(actualParseTimestamp);
|
|
54
|
+
});
|
|
55
|
+
afterEach(() => {
|
|
56
|
+
mocks.parseTimestamp.mockReset();
|
|
40
57
|
});
|
|
41
58
|
|
|
42
|
-
it("should correctly parse regular cue blocks",
|
|
43
|
-
const parseCueBlock = (await vi.importActual("../parse_cue_block"))
|
|
44
|
-
.default as typeof IParseCueBlock;
|
|
59
|
+
it("should correctly parse regular cue blocks", () => {
|
|
45
60
|
expect(parseCueBlock(cueBlock1, 0)).toEqual({
|
|
46
61
|
start: 31.08,
|
|
47
62
|
end: 452.2,
|
|
@@ -87,9 +102,7 @@ describe("parsers - srt - parseCueBlocks", () => {
|
|
|
87
102
|
});
|
|
88
103
|
});
|
|
89
104
|
|
|
90
|
-
it("should add timeOffset in seconds",
|
|
91
|
-
const parseCueBlock = (await vi.importActual("../parse_cue_block"))
|
|
92
|
-
.default as typeof IParseCueBlock;
|
|
105
|
+
it("should add timeOffset in seconds", () => {
|
|
93
106
|
expect(parseCueBlock(cueBlock1, 10.1)).toEqual({
|
|
94
107
|
start: 41.18,
|
|
95
108
|
end: 462.3,
|
|
@@ -146,9 +159,7 @@ describe("parsers - srt - parseCueBlocks", () => {
|
|
|
146
159
|
});
|
|
147
160
|
});
|
|
148
161
|
|
|
149
|
-
it("should return null for invalid cue blocks",
|
|
150
|
-
const parseCueBlock = (await vi.importActual("../parse_cue_block"))
|
|
151
|
-
.default as typeof IParseCueBlock;
|
|
162
|
+
it("should return null for invalid cue blocks", () => {
|
|
152
163
|
expect(parseCueBlock(notCueBlock1, 0)).toEqual(null);
|
|
153
164
|
expect(parseCueBlock(notCueBlock1, 5)).toEqual(null);
|
|
154
165
|
expect(parseCueBlock(notCueBlock2, 0)).toEqual(null);
|
|
@@ -161,27 +172,19 @@ describe("parsers - srt - parseCueBlocks", () => {
|
|
|
161
172
|
expect(parseCueBlock(notCueBlock7, 0)).toEqual(null);
|
|
162
173
|
});
|
|
163
174
|
|
|
164
|
-
it("should return null if parseTimestamp returns undefined either for the starting timestamp",
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}));
|
|
169
|
-
const parseCueBlock = (await vi.importActual("../parse_cue_block"))
|
|
170
|
-
.default as typeof IParseCueBlock;
|
|
171
|
-
|
|
175
|
+
it("should return null if parseTimestamp returns undefined either for the starting timestamp", () => {
|
|
176
|
+
mocks.parseTimestamp.mockImplementation((arg) =>
|
|
177
|
+
arg === "00:00:31.080" ? undefined : 10,
|
|
178
|
+
);
|
|
172
179
|
expect(parseCueBlock(cueBlock1, 0)).toEqual(null);
|
|
173
|
-
expect(parseTimestamp).toHaveBeenCalledTimes(2);
|
|
180
|
+
expect(mocks.parseTimestamp).toHaveBeenCalledTimes(2);
|
|
174
181
|
});
|
|
175
182
|
|
|
176
|
-
it("should return null if parseTimestamp returns undefined either for the ending timestamp",
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}));
|
|
181
|
-
const parseCueBlock = (await vi.importActual("../parse_cue_block"))
|
|
182
|
-
.default as typeof IParseCueBlock;
|
|
183
|
-
|
|
183
|
+
it("should return null if parseTimestamp returns undefined either for the ending timestamp", () => {
|
|
184
|
+
mocks.parseTimestamp.mockImplementation((arg) =>
|
|
185
|
+
arg === "00:07:32.200" ? undefined : 10,
|
|
186
|
+
);
|
|
184
187
|
expect(parseCueBlock(cueBlock1, 0)).toEqual(null);
|
|
185
|
-
expect(parseTimestamp).toHaveBeenCalledTimes(2);
|
|
188
|
+
expect(mocks.parseTimestamp).toHaveBeenCalledTimes(2);
|
|
186
189
|
});
|
|
187
190
|
});
|
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import { describe, beforeEach, it, expect, vi } from "vitest";
|
|
2
|
-
import
|
|
2
|
+
import parseStyleBlock from "../parse_style_block";
|
|
3
|
+
|
|
4
|
+
const mocks = vi.hoisted(() => {
|
|
5
|
+
return {
|
|
6
|
+
createDefaultStyleElements: vi.fn(),
|
|
7
|
+
};
|
|
8
|
+
});
|
|
9
|
+
vi.mock("../create_default_style_elements", () => ({
|
|
10
|
+
default: mocks.createDefaultStyleElements,
|
|
11
|
+
}));
|
|
3
12
|
|
|
4
13
|
describe("parsers - webvtt - parseStyleBlock", () => {
|
|
5
14
|
beforeEach(() => {
|
|
6
15
|
vi.resetModules();
|
|
16
|
+
mocks.createDefaultStyleElements.mockReset();
|
|
7
17
|
});
|
|
8
18
|
|
|
9
|
-
it("should correctly handle empty style blocks",
|
|
19
|
+
it("should correctly handle empty style blocks", () => {
|
|
10
20
|
const webvttStyle = [["STYLE"], []];
|
|
21
|
+
mocks.createDefaultStyleElements.mockImplementation(() => ({}));
|
|
11
22
|
|
|
12
|
-
const mockCreateDefaultStyleElements = vi.fn(() => ({}));
|
|
13
|
-
vi.doMock("../create_default_style_elements", () => ({
|
|
14
|
-
default: () => {
|
|
15
|
-
return mockCreateDefaultStyleElements();
|
|
16
|
-
},
|
|
17
|
-
}));
|
|
18
|
-
const parseStyleBlock = (await vi.importActual("../parse_style_block"))
|
|
19
|
-
.default as typeof IParseStyleBlock;
|
|
20
23
|
expect(parseStyleBlock(webvttStyle)).toEqual({
|
|
21
24
|
classes: {},
|
|
22
25
|
global: "",
|
|
23
26
|
});
|
|
24
27
|
});
|
|
25
28
|
|
|
26
|
-
it("should parse global style",
|
|
29
|
+
it("should parse global style", () => {
|
|
27
30
|
const webvttStyle = [
|
|
28
31
|
[
|
|
29
32
|
"STYLE",
|
|
@@ -33,15 +36,8 @@ describe("parsers - webvtt - parseStyleBlock", () => {
|
|
|
33
36
|
"}",
|
|
34
37
|
],
|
|
35
38
|
];
|
|
39
|
+
mocks.createDefaultStyleElements.mockImplementation(() => ({}));
|
|
36
40
|
|
|
37
|
-
const mockCreateDefaultStyleElements = vi.fn(() => ({}));
|
|
38
|
-
vi.doMock("../create_default_style_elements", () => ({
|
|
39
|
-
default: () => {
|
|
40
|
-
return mockCreateDefaultStyleElements();
|
|
41
|
-
},
|
|
42
|
-
}));
|
|
43
|
-
const parseStyleBlock = (await vi.importActual("../parse_style_block"))
|
|
44
|
-
.default as typeof IParseStyleBlock;
|
|
45
41
|
expect(parseStyleBlock(webvttStyle)).toEqual({
|
|
46
42
|
classes: {},
|
|
47
43
|
global:
|
|
@@ -50,17 +46,10 @@ describe("parsers - webvtt - parseStyleBlock", () => {
|
|
|
50
46
|
});
|
|
51
47
|
});
|
|
52
48
|
|
|
53
|
-
it("should parse class style",
|
|
49
|
+
it("should parse class style", () => {
|
|
54
50
|
const webvttStyle = [["STYLE", "::cue(b) {", " color: peachpuff;", "}"]];
|
|
51
|
+
mocks.createDefaultStyleElements.mockImplementation(() => ({}));
|
|
55
52
|
|
|
56
|
-
const mockCreateDefaultStyleElements = vi.fn(() => ({}));
|
|
57
|
-
vi.doMock("../create_default_style_elements", () => ({
|
|
58
|
-
default: () => {
|
|
59
|
-
return mockCreateDefaultStyleElements();
|
|
60
|
-
},
|
|
61
|
-
}));
|
|
62
|
-
const parseStyleBlock = (await vi.importActual("../parse_style_block"))
|
|
63
|
-
.default as typeof IParseStyleBlock;
|
|
64
53
|
expect(parseStyleBlock(webvttStyle)).toEqual({
|
|
65
54
|
classes: {
|
|
66
55
|
b: " color: peachpuff;",
|
|
@@ -69,7 +58,7 @@ describe("parsers - webvtt - parseStyleBlock", () => {
|
|
|
69
58
|
});
|
|
70
59
|
});
|
|
71
60
|
|
|
72
|
-
it("should parse both global and class style",
|
|
61
|
+
it("should parse both global and class style", () => {
|
|
73
62
|
const webvttStyle = [
|
|
74
63
|
[
|
|
75
64
|
"STYLE",
|
|
@@ -80,15 +69,8 @@ describe("parsers - webvtt - parseStyleBlock", () => {
|
|
|
80
69
|
],
|
|
81
70
|
["STYLE", "::cue(b) {", " color: peachpuff;", "}"],
|
|
82
71
|
];
|
|
72
|
+
mocks.createDefaultStyleElements.mockImplementation(() => ({}));
|
|
83
73
|
|
|
84
|
-
const mockCreateDefaultStyleElements = vi.fn(() => ({}));
|
|
85
|
-
vi.doMock("../create_default_style_elements", () => ({
|
|
86
|
-
default: () => {
|
|
87
|
-
return mockCreateDefaultStyleElements();
|
|
88
|
-
},
|
|
89
|
-
}));
|
|
90
|
-
const parseStyleBlock = (await vi.importActual("../parse_style_block"))
|
|
91
|
-
.default as typeof IParseStyleBlock;
|
|
92
74
|
expect(parseStyleBlock(webvttStyle)).toEqual({
|
|
93
75
|
global:
|
|
94
76
|
"background-image: linear-gradient(to bottom, dimgray, lightgray);" +
|
|
@@ -99,20 +81,13 @@ describe("parsers - webvtt - parseStyleBlock", () => {
|
|
|
99
81
|
});
|
|
100
82
|
});
|
|
101
83
|
|
|
102
|
-
it("should not parse unformed styles",
|
|
84
|
+
it("should not parse unformed styles", () => {
|
|
103
85
|
const webvttStyle = [
|
|
104
86
|
["BAD STYLE"],
|
|
105
87
|
["STYLE", "::cue(b) {", " color: peachpuff;", "}"],
|
|
106
88
|
];
|
|
89
|
+
mocks.createDefaultStyleElements.mockImplementation(() => ({}));
|
|
107
90
|
|
|
108
|
-
const mockCreateDefaultStyleElements = vi.fn(() => ({}));
|
|
109
|
-
vi.doMock("../create_default_style_elements", () => ({
|
|
110
|
-
default: () => {
|
|
111
|
-
return mockCreateDefaultStyleElements();
|
|
112
|
-
},
|
|
113
|
-
}));
|
|
114
|
-
const parseStyleBlock = (await vi.importActual("../parse_style_block"))
|
|
115
|
-
.default as typeof IParseStyleBlock;
|
|
116
91
|
expect(parseStyleBlock(webvttStyle)).toEqual({
|
|
117
92
|
classes: {
|
|
118
93
|
b: " color: peachpuff;",
|
|
@@ -121,20 +96,13 @@ describe("parsers - webvtt - parseStyleBlock", () => {
|
|
|
121
96
|
});
|
|
122
97
|
});
|
|
123
98
|
|
|
124
|
-
it("should not override styles if class if declared several times",
|
|
99
|
+
it("should not override styles if class if declared several times", () => {
|
|
125
100
|
const webvttStyle = [
|
|
126
101
|
["STYLE", "::cue(b) {", " color: peachpuff;", "}"],
|
|
127
102
|
["STYLE", "::cue(b) {", " background-color: dark;", "}"],
|
|
128
103
|
];
|
|
104
|
+
mocks.createDefaultStyleElements.mockImplementation(() => ({}));
|
|
129
105
|
|
|
130
|
-
const mockCreateDefaultStyleElements = vi.fn(() => ({}));
|
|
131
|
-
vi.doMock("../create_default_style_elements", () => ({
|
|
132
|
-
default: () => {
|
|
133
|
-
return mockCreateDefaultStyleElements();
|
|
134
|
-
},
|
|
135
|
-
}));
|
|
136
|
-
const parseStyleBlock = (await vi.importActual("../parse_style_block"))
|
|
137
|
-
.default as typeof IParseStyleBlock;
|
|
138
106
|
expect(parseStyleBlock(webvttStyle)).toEqual({
|
|
139
107
|
classes: {
|
|
140
108
|
b: " color: peachpuff; background-color: dark;",
|
|
@@ -143,7 +111,7 @@ describe("parsers - webvtt - parseStyleBlock", () => {
|
|
|
143
111
|
});
|
|
144
112
|
});
|
|
145
113
|
|
|
146
|
-
it("should take into account all cues declared in one style block",
|
|
114
|
+
it("should take into account all cues declared in one style block", () => {
|
|
147
115
|
const webvttStyle = [
|
|
148
116
|
[
|
|
149
117
|
"STYLE",
|
|
@@ -155,15 +123,8 @@ describe("parsers - webvtt - parseStyleBlock", () => {
|
|
|
155
123
|
"}",
|
|
156
124
|
],
|
|
157
125
|
];
|
|
126
|
+
mocks.createDefaultStyleElements.mockImplementation(() => ({}));
|
|
158
127
|
|
|
159
|
-
const mockCreateDefaultStyleElements = vi.fn(() => ({}));
|
|
160
|
-
vi.doMock("../create_default_style_elements", () => ({
|
|
161
|
-
default: () => {
|
|
162
|
-
return mockCreateDefaultStyleElements();
|
|
163
|
-
},
|
|
164
|
-
}));
|
|
165
|
-
const parseStyleBlock = (await vi.importActual("../parse_style_block"))
|
|
166
|
-
.default as typeof IParseStyleBlock;
|
|
167
128
|
expect(parseStyleBlock(webvttStyle)).toEqual({
|
|
168
129
|
classes: {
|
|
169
130
|
b: " background-color: dark;",
|
|
@@ -172,7 +133,7 @@ describe("parsers - webvtt - parseStyleBlock", () => {
|
|
|
172
133
|
});
|
|
173
134
|
});
|
|
174
135
|
|
|
175
|
-
it("should consider a cue declared in multi-cue and mono-cue style blocks",
|
|
136
|
+
it("should consider a cue declared in multi-cue and mono-cue style blocks", () => {
|
|
176
137
|
const webvttStyle = [
|
|
177
138
|
[
|
|
178
139
|
"STYLE",
|
|
@@ -185,15 +146,8 @@ describe("parsers - webvtt - parseStyleBlock", () => {
|
|
|
185
146
|
],
|
|
186
147
|
["STYLE", "::cue(b) {", " color: salmon;", "}"],
|
|
187
148
|
];
|
|
149
|
+
mocks.createDefaultStyleElements.mockImplementation(() => ({}));
|
|
188
150
|
|
|
189
|
-
const mockCreateDefaultStyleElements = vi.fn(() => ({}));
|
|
190
|
-
vi.doMock("../create_default_style_elements", () => ({
|
|
191
|
-
default: () => {
|
|
192
|
-
return mockCreateDefaultStyleElements();
|
|
193
|
-
},
|
|
194
|
-
}));
|
|
195
|
-
const parseStyleBlock = (await vi.importActual("../parse_style_block"))
|
|
196
|
-
.default as typeof IParseStyleBlock;
|
|
197
151
|
expect(parseStyleBlock(webvttStyle)).toEqual({
|
|
198
152
|
classes: {
|
|
199
153
|
b: " background-color: dark; color: salmon;",
|
|
@@ -201,7 +155,7 @@ describe("parsers - webvtt - parseStyleBlock", () => {
|
|
|
201
155
|
global: " color: peachpuff;",
|
|
202
156
|
});
|
|
203
157
|
});
|
|
204
|
-
it("should consider a cue declared in multi-cue and mono-cue style blocks",
|
|
158
|
+
it("should consider a cue declared in multi-cue and mono-cue style blocks", () => {
|
|
205
159
|
const webvttStyle = [
|
|
206
160
|
[
|
|
207
161
|
"STYLE",
|
|
@@ -214,15 +168,8 @@ describe("parsers - webvtt - parseStyleBlock", () => {
|
|
|
214
168
|
],
|
|
215
169
|
["STYLE", "::cue(b) {", " color: salmon;", "}"],
|
|
216
170
|
];
|
|
171
|
+
mocks.createDefaultStyleElements.mockImplementation(() => ({}));
|
|
217
172
|
|
|
218
|
-
const mockCreateDefaultStyleElements = vi.fn(() => ({}));
|
|
219
|
-
vi.doMock("../create_default_style_elements", () => ({
|
|
220
|
-
default: () => {
|
|
221
|
-
return mockCreateDefaultStyleElements();
|
|
222
|
-
},
|
|
223
|
-
}));
|
|
224
|
-
const parseStyleBlock = (await vi.importActual("../parse_style_block"))
|
|
225
|
-
.default as typeof IParseStyleBlock;
|
|
226
173
|
expect(parseStyleBlock(webvttStyle)).toEqual({
|
|
227
174
|
classes: {
|
|
228
175
|
b: " background-color: dark; color: salmon;",
|
|
@@ -231,20 +178,13 @@ describe("parsers - webvtt - parseStyleBlock", () => {
|
|
|
231
178
|
});
|
|
232
179
|
});
|
|
233
180
|
|
|
234
|
-
it("should consider multiple class declaration for one stylesheet",
|
|
181
|
+
it("should consider multiple class declaration for one stylesheet", () => {
|
|
235
182
|
const webvttStyle = [
|
|
236
183
|
["STYLE", "::cue(c),", "::cue(d),", "::cue(b) {", " background-color: dark;", "}"],
|
|
237
184
|
["STYLE", "::cue(c) {", " color: salmon;", "}"],
|
|
238
185
|
];
|
|
186
|
+
mocks.createDefaultStyleElements.mockImplementation(() => ({}));
|
|
239
187
|
|
|
240
|
-
const mockCreateDefaultStyleElements = vi.fn(() => ({}));
|
|
241
|
-
vi.doMock("../create_default_style_elements", () => ({
|
|
242
|
-
default: () => {
|
|
243
|
-
return mockCreateDefaultStyleElements();
|
|
244
|
-
},
|
|
245
|
-
}));
|
|
246
|
-
const parseStyleBlock = (await vi.importActual("../parse_style_block"))
|
|
247
|
-
.default as typeof IParseStyleBlock;
|
|
248
188
|
expect(parseStyleBlock(webvttStyle)).toEqual({
|
|
249
189
|
classes: {
|
|
250
190
|
b: " background-color: dark;",
|
|
@@ -255,17 +195,10 @@ describe("parsers - webvtt - parseStyleBlock", () => {
|
|
|
255
195
|
});
|
|
256
196
|
});
|
|
257
197
|
|
|
258
|
-
it("should return empty style if no style block",
|
|
198
|
+
it("should return empty style if no style block", () => {
|
|
259
199
|
const webvttStyle: string[][] = [];
|
|
200
|
+
mocks.createDefaultStyleElements.mockImplementation(() => ({}));
|
|
260
201
|
|
|
261
|
-
const mockCreateDefaultStyleElements = vi.fn(() => ({}));
|
|
262
|
-
vi.doMock("../create_default_style_elements", () => ({
|
|
263
|
-
default: () => {
|
|
264
|
-
return mockCreateDefaultStyleElements();
|
|
265
|
-
},
|
|
266
|
-
}));
|
|
267
|
-
const parseStyleBlock = (await vi.importActual("../parse_style_block"))
|
|
268
|
-
.default as typeof IParseStyleBlock;
|
|
269
202
|
expect(parseStyleBlock(webvttStyle)).toEqual({
|
|
270
203
|
classes: {},
|
|
271
204
|
global: "",
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import { describe, beforeEach, it, expect, vi } from "vitest";
|
|
2
2
|
import globalScope from "../../../../../utils/global_scope";
|
|
3
|
-
import
|
|
3
|
+
import convertPayloadToHTML from "../convert_payload_to_html";
|
|
4
|
+
|
|
5
|
+
const mocks = vi.hoisted(() => {
|
|
6
|
+
return {
|
|
7
|
+
createStyledElement: vi.fn(),
|
|
8
|
+
};
|
|
9
|
+
});
|
|
10
|
+
vi.mock("../create_styled_element", () => ({
|
|
11
|
+
default: mocks.createStyledElement,
|
|
12
|
+
}));
|
|
4
13
|
|
|
5
14
|
describe("parsers - webvtt - convertPayloadToHTML", () => {
|
|
6
15
|
beforeEach(() => {
|
|
7
16
|
vi.resetModules();
|
|
17
|
+
mocks.createStyledElement.mockReset();
|
|
8
18
|
});
|
|
9
19
|
|
|
10
20
|
const gs = globalScope as {
|
|
11
21
|
DOMParser: unknown;
|
|
12
22
|
};
|
|
13
|
-
it("should return empty payload when input text is empty",
|
|
23
|
+
it("should return empty payload when input text is empty", () => {
|
|
14
24
|
const spyParseFromString = vi.fn(() => {
|
|
15
25
|
return {
|
|
16
26
|
body: {
|
|
@@ -26,20 +36,13 @@ describe("parsers - webvtt - convertPayloadToHTML", () => {
|
|
|
26
36
|
}
|
|
27
37
|
};
|
|
28
38
|
|
|
29
|
-
const spy = vi.fn();
|
|
30
|
-
vi.doMock("../create_styled_element", () => ({
|
|
31
|
-
default: spy,
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
const convertPayloadToHTML = (await vi.importActual("../convert_payload_to_html"))
|
|
35
|
-
.default as typeof IConvertPayloadToHTML;
|
|
36
39
|
expect(convertPayloadToHTML("", {})).toEqual([]);
|
|
37
40
|
expect(spyParseFromString).toHaveBeenCalledTimes(1);
|
|
38
|
-
expect(
|
|
41
|
+
expect(mocks.createStyledElement).not.toHaveBeenCalled();
|
|
39
42
|
gs.DOMParser = origDOMParser;
|
|
40
43
|
});
|
|
41
44
|
|
|
42
|
-
it("should convert normal input text with no style",
|
|
45
|
+
it("should convert normal input text with no style", () => {
|
|
43
46
|
const innerText = "<b></b>Hello";
|
|
44
47
|
const bNode = document.createElement("b");
|
|
45
48
|
const textNode = document.createTextNode("Hello");
|
|
@@ -53,16 +56,13 @@ describe("parsers - webvtt - convertPayloadToHTML", () => {
|
|
|
53
56
|
|
|
54
57
|
const span = document.createElement("span");
|
|
55
58
|
span.textContent = "Hello";
|
|
56
|
-
|
|
59
|
+
mocks.createStyledElement.mockImplementation((input: Node) => {
|
|
57
60
|
if (input.nodeName === bNode.nodeName) {
|
|
58
61
|
return bNode;
|
|
59
62
|
} else if (input.nodeName === textNode.nodeName) {
|
|
60
63
|
return span;
|
|
61
64
|
}
|
|
62
65
|
});
|
|
63
|
-
vi.doMock("../create_styled_element", () => ({
|
|
64
|
-
default: spyCreateStyledElement,
|
|
65
|
-
}));
|
|
66
66
|
|
|
67
67
|
const origDOMParser = gs.DOMParser;
|
|
68
68
|
gs.DOMParser = class MockDOMParser {
|
|
@@ -71,11 +71,9 @@ describe("parsers - webvtt - convertPayloadToHTML", () => {
|
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
const convertPayloadToHTML = (await vi.importActual("../convert_payload_to_html"))
|
|
75
|
-
.default as typeof IConvertPayloadToHTML;
|
|
76
74
|
expect(convertPayloadToHTML(innerText, {})).toEqual([bNode, span]);
|
|
77
75
|
expect(spyParseFromString).toHaveBeenCalledTimes(1);
|
|
78
|
-
expect(
|
|
76
|
+
expect(mocks.createStyledElement).toHaveBeenCalledTimes(2);
|
|
79
77
|
gs.DOMParser = origDOMParser;
|
|
80
78
|
});
|
|
81
79
|
});
|
|
@@ -1,79 +1,94 @@
|
|
|
1
|
-
import { describe, beforeEach, it, expect, vi } from "vitest";
|
|
2
|
-
import
|
|
1
|
+
import { describe, beforeEach, it, expect, vi, afterEach } from "vitest";
|
|
2
|
+
import parseWebVTT from "../parse_webvtt_plain_text";
|
|
3
|
+
|
|
4
|
+
const mocks = vi.hoisted(() => {
|
|
5
|
+
return {
|
|
6
|
+
getStyleBlocks: vi.fn(),
|
|
7
|
+
getCueBlocks: vi.fn(),
|
|
8
|
+
parseStyleBlock: vi.fn(),
|
|
9
|
+
parseCueBlock: vi.fn(),
|
|
10
|
+
toHtml: vi.fn(),
|
|
11
|
+
getFirstLineAfterHeader: vi.fn(),
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
vi.mock("../../get_style_blocks", () => ({
|
|
15
|
+
default: mocks.getStyleBlocks,
|
|
16
|
+
}));
|
|
17
|
+
vi.mock("../../get_cue_blocks", () => ({
|
|
18
|
+
default: mocks.getCueBlocks,
|
|
19
|
+
}));
|
|
20
|
+
vi.mock("../../parse_cue_block", () => ({
|
|
21
|
+
default: mocks.parseCueBlock,
|
|
22
|
+
}));
|
|
23
|
+
vi.mock("../../parse_style_block", () => ({
|
|
24
|
+
default: mocks.parseStyleBlock,
|
|
25
|
+
}));
|
|
26
|
+
vi.mock("../to_html", () => ({
|
|
27
|
+
default: mocks.toHtml,
|
|
28
|
+
}));
|
|
29
|
+
vi.mock("../../utils", () => ({
|
|
30
|
+
getFirstLineAfterHeader: mocks.getFirstLineAfterHeader,
|
|
31
|
+
}));
|
|
3
32
|
|
|
4
33
|
describe("parsers - webvtt - parseWebVTT", () => {
|
|
5
34
|
beforeEach(() => {
|
|
6
35
|
vi.resetModules();
|
|
7
36
|
});
|
|
37
|
+
afterEach(() => {
|
|
38
|
+
mocks.getStyleBlocks.mockReset();
|
|
39
|
+
mocks.getCueBlocks.mockReset();
|
|
40
|
+
mocks.parseStyleBlock.mockReset();
|
|
41
|
+
mocks.parseCueBlock.mockReset();
|
|
42
|
+
mocks.toHtml.mockReset();
|
|
43
|
+
mocks.getFirstLineAfterHeader.mockReset();
|
|
44
|
+
});
|
|
8
45
|
|
|
9
|
-
it("should throw if text is empty",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
46
|
+
it("should throw if text is empty", () => {
|
|
47
|
+
expect(() => parseWebVTT("", {}, 0)).toThrowError(
|
|
48
|
+
"Can't parse WebVTT: Invalid File.",
|
|
49
|
+
);
|
|
13
50
|
});
|
|
14
51
|
|
|
15
|
-
it("should throw if file seems to be invalid",
|
|
16
|
-
|
|
17
|
-
.default as typeof IParseWebVTTPlainText;
|
|
18
|
-
expect(() => parseWebVTT("WEBWTT\n", 1, 0)).toThrowError(
|
|
52
|
+
it("should throw if file seems to be invalid", () => {
|
|
53
|
+
expect(() => parseWebVTT("WEBWTT\n", {}, 0)).toThrowError(
|
|
19
54
|
"Can't parse WebVTT: Invalid File.",
|
|
20
55
|
);
|
|
21
56
|
});
|
|
22
57
|
|
|
23
|
-
it("should return cues if inner contains right cues",
|
|
24
|
-
|
|
58
|
+
it("should return cues if inner contains right cues", () => {
|
|
59
|
+
mocks.getStyleBlocks.mockImplementation(() => [
|
|
25
60
|
["STYLE", ""],
|
|
26
61
|
["STYLE", ""],
|
|
27
62
|
]);
|
|
28
|
-
vi.doMock("../../get_style_blocks", () => ({
|
|
29
|
-
default: spyGetStyleBlock,
|
|
30
|
-
}));
|
|
31
63
|
|
|
32
|
-
|
|
64
|
+
mocks.getCueBlocks.mockImplementation(() => [
|
|
33
65
|
["CUE", ""],
|
|
34
66
|
["CUE", ""],
|
|
35
67
|
]);
|
|
36
|
-
vi.doMock("../../get_cue_blocks", () => ({
|
|
37
|
-
default: spyGetCueBlock,
|
|
38
|
-
}));
|
|
39
68
|
|
|
40
|
-
|
|
69
|
+
mocks.parseCueBlock.mockImplementation(() => ({
|
|
41
70
|
start: 0,
|
|
42
71
|
end: 100,
|
|
43
72
|
payload: "<b>Test</b>Bonjour",
|
|
44
73
|
header: "b",
|
|
45
74
|
settings: {},
|
|
46
75
|
}));
|
|
47
|
-
vi.doMock("../../parse_cue_block", () => ({
|
|
48
|
-
default: spyParseCueBlock,
|
|
49
|
-
}));
|
|
50
76
|
|
|
51
|
-
|
|
77
|
+
mocks.parseStyleBlock.mockImplementation(() => ({
|
|
52
78
|
b: {
|
|
53
79
|
styleContent: "color:blue;",
|
|
54
80
|
},
|
|
55
81
|
}));
|
|
56
|
-
vi.doMock("../../parse_style_block", () => ({
|
|
57
|
-
default: spyParseStyleBlock,
|
|
58
|
-
}));
|
|
59
82
|
|
|
60
|
-
|
|
83
|
+
mocks.toHtml.mockImplementation(() => ({
|
|
61
84
|
start: 0,
|
|
62
85
|
end: 100,
|
|
63
86
|
element: document.createElement("div"),
|
|
64
87
|
}));
|
|
65
|
-
vi.doMock("../to_html", () => ({
|
|
66
|
-
default: spyToHTML,
|
|
67
|
-
}));
|
|
68
88
|
|
|
69
|
-
|
|
70
|
-
vi.doMock("../../utils", () => ({
|
|
71
|
-
getFirstLineAfterHeader: spyGetFirstLineAfterHeader,
|
|
72
|
-
}));
|
|
89
|
+
mocks.getFirstLineAfterHeader.mockImplementation(() => 1);
|
|
73
90
|
|
|
74
|
-
|
|
75
|
-
.default as typeof IParseWebVTTPlainText;
|
|
76
|
-
expect(parseWebVTT("WEBVTT\n", 1, 0)).toEqual([
|
|
91
|
+
expect(parseWebVTT("WEBVTT\n", {}, 0)).toEqual([
|
|
77
92
|
{
|
|
78
93
|
element: document.createElement("div"),
|
|
79
94
|
end: 100,
|
|
@@ -85,67 +100,47 @@ describe("parsers - webvtt - parseWebVTT", () => {
|
|
|
85
100
|
start: 0,
|
|
86
101
|
},
|
|
87
102
|
]);
|
|
88
|
-
expect(
|
|
89
|
-
expect(
|
|
90
|
-
expect(
|
|
91
|
-
expect(
|
|
92
|
-
expect(
|
|
93
|
-
expect(
|
|
103
|
+
expect(mocks.getFirstLineAfterHeader).toHaveBeenCalledTimes(1);
|
|
104
|
+
expect(mocks.getStyleBlocks).toHaveBeenCalledTimes(1);
|
|
105
|
+
expect(mocks.getCueBlocks).toHaveBeenCalledTimes(1);
|
|
106
|
+
expect(mocks.parseStyleBlock).toHaveBeenCalledTimes(1);
|
|
107
|
+
expect(mocks.parseCueBlock).toHaveBeenCalledTimes(2);
|
|
108
|
+
expect(mocks.toHtml).toHaveBeenCalledTimes(2);
|
|
94
109
|
});
|
|
95
110
|
|
|
96
|
-
it("should return empty array if cue blocks can't be parsed",
|
|
97
|
-
|
|
111
|
+
it("should return empty array if cue blocks can't be parsed", () => {
|
|
112
|
+
mocks.getStyleBlocks.mockImplementation(() => [
|
|
98
113
|
["STYLE", ""],
|
|
99
114
|
["STYLE", ""],
|
|
100
115
|
]);
|
|
101
|
-
vi.doMock("../../get_style_blocks", () => ({
|
|
102
|
-
default: spyGetStyleBlock,
|
|
103
|
-
}));
|
|
104
116
|
|
|
105
|
-
|
|
117
|
+
mocks.getCueBlocks.mockImplementation(() => [
|
|
106
118
|
["CUE", ""],
|
|
107
119
|
["CUE", ""],
|
|
108
120
|
]);
|
|
109
|
-
vi.doMock("../../get_cue_blocks", () => ({
|
|
110
|
-
default: spyGetCueBlock,
|
|
111
|
-
}));
|
|
112
121
|
|
|
113
|
-
|
|
114
|
-
vi.doMock("../../parse_cue_block", () => ({
|
|
115
|
-
default: spyParseCueBlock,
|
|
116
|
-
}));
|
|
122
|
+
mocks.parseCueBlock.mockImplementation(() => null);
|
|
117
123
|
|
|
118
|
-
|
|
124
|
+
mocks.parseStyleBlock.mockImplementation(() => ({
|
|
119
125
|
b: {
|
|
120
126
|
styleContent: "color:blue;",
|
|
121
127
|
},
|
|
122
128
|
}));
|
|
123
|
-
vi.doMock("../../parse_style_block", () => ({
|
|
124
|
-
default: spyParseStyleBlock,
|
|
125
|
-
}));
|
|
126
129
|
|
|
127
|
-
|
|
130
|
+
mocks.toHtml.mockImplementation(() => ({
|
|
128
131
|
start: 0,
|
|
129
132
|
end: 100,
|
|
130
133
|
element: document.createElement("div"),
|
|
131
134
|
}));
|
|
132
|
-
vi.doMock("../to_html", () => ({
|
|
133
|
-
default: spyToHTML,
|
|
134
|
-
}));
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
vi.doMock("../../utils", () => ({
|
|
138
|
-
getFirstLineAfterHeader: spyGetFirstLineAfterHeader,
|
|
139
|
-
}));
|
|
136
|
+
mocks.getFirstLineAfterHeader.mockImplementation(() => 1);
|
|
140
137
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
expect(
|
|
144
|
-
expect(
|
|
145
|
-
expect(
|
|
146
|
-
expect(
|
|
147
|
-
expect(
|
|
148
|
-
expect(spyParseCueBlock).toHaveBeenCalledTimes(2);
|
|
149
|
-
expect(spyToHTML).not.toHaveBeenCalled();
|
|
138
|
+
expect(parseWebVTT("WEBVTT\n", {}, 0)).toEqual([]);
|
|
139
|
+
expect(mocks.getFirstLineAfterHeader).toHaveBeenCalledTimes(1);
|
|
140
|
+
expect(mocks.getStyleBlocks).toHaveBeenCalledTimes(1);
|
|
141
|
+
expect(mocks.getCueBlocks).toHaveBeenCalledTimes(1);
|
|
142
|
+
expect(mocks.parseStyleBlock).toHaveBeenCalledTimes(1);
|
|
143
|
+
expect(mocks.parseCueBlock).toHaveBeenCalledTimes(2);
|
|
144
|
+
expect(mocks.toHtml).not.toHaveBeenCalled();
|
|
150
145
|
});
|
|
151
146
|
});
|