Skip to content

Commit

Permalink
tests: Fix and work around remaining unit test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
peaBerberian committed Jun 11, 2024
1 parent 18099c4 commit 7e2ea17
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/main_thread/decrypt/__tests__/__global__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,5 +515,11 @@ export function formatFakeChallengeFromInitData(
): Uint8Array {
const initDataAB = initData instanceof ArrayBuffer ? initData : initData.buffer;
const objChallenge = [initDataType, bytesToBase64(new Uint8Array(initDataAB))];
return strToUtf8(JSON.stringify(objChallenge));
let data = strToUtf8(JSON.stringify(objChallenge));
// Work-around some testing environment issue
// see https://github.com/vitest-dev/vitest/issues/4043
if (!(data instanceof Uint8Array)) {
data = new Uint8Array(data);
}
return data;
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,24 @@ describe("Global TTML HTML parsing tests", () => {
return currTextNodes;
}
let nbTextNodes = 0;
const textNodes = findTextNodes(res[6].element);
for (let i = 0; i < textNodes.length; i++) {
const parentElement = textNodes[i].parentElement;
if (parentElement !== null) {
expect(globalScope.getComputedStyle(parentElement).color).toEqual("yellow");
nbTextNodes++;
{
const textNodes = findTextNodes(res[5].element);
for (let i = 0; i < textNodes.length; i++) {
const parentElement = textNodes[i].parentElement;
if (parentElement !== null) {
expect(globalScope.getComputedStyle(parentElement).color).toEqual("yellow");
nbTextNodes++;
}
}
}
{
const textNodes = findTextNodes(res[6].element);
for (let i = 0; i < textNodes.length; i++) {
const parentElement = textNodes[i].parentElement;
if (parentElement !== null) {
expect(globalScope.getComputedStyle(parentElement).color).toEqual("white");
nbTextNodes++;
}
}
}
expect(nbTextNodes).toBeGreaterThanOrEqual(1);
Expand Down

0 comments on commit 7e2ea17

Please sign in to comment.