Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Test StringUtils both with and without TextDecoder #4405

Merged
merged 1 commit into from
Aug 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion test/util/string_utils_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@
*/

describe('StringUtils', () => {
describe('with TextDecoder', () => {
if (window.TextDecoder) {
defineStringUtilTests();
}
});

describe('without TextDecoder', () => {
let originalTextDecoder;

beforeAll(() => {
originalTextDecoder = window.TextDecoder;
window['TextDecoder'] = null;
});

afterAll(() => {
window.TextDecoder = originalTextDecoder;
});

defineStringUtilTests();
});
});

function defineStringUtilTests() {
const StringUtils = shaka.util.StringUtils;

it('parses fromUTF8', () => {
Expand Down Expand Up @@ -140,4 +163,4 @@ describe('StringUtils', () => {
expect(StringUtils.fromUTF16(buffer, true).length)
.toBe(buffer.byteLength / 2);
});
});
}