[SG-31914] Fix failing unit tests on client/common, client/codeintellify packages (#32241)

* fix: unit tests in client/common client/codeintellify

* chore: decrease TOOLTIP_DISPLAY_DELAY

Co-authored-by: gitstart-sourcegraph <gitstart@users.noreply.github.com>
This commit is contained in:
GitStart-SourceGraph 2022-03-08 22:55:50 +08:00 committed by GitHub
parent 705df1330b
commit 93eebb8b84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 5 deletions

View File

@ -25,8 +25,7 @@ import {
} from './testutils/fixtures'
import { dispatchMouseEventAtPositionImpure } from './testutils/mouse'
// TODOD #31952: Some of these tests are failing. They should be fixed and made to run in CI, or deleted.
describe.skip('Hoverifier', () => {
describe('Hoverifier', () => {
const dom = new DOM()
afterAll(dom.cleanup)

View File

@ -346,7 +346,7 @@ const internalToExternalState = <C extends object, D, A>(
export const LOADER_DELAY = 600
/** The time in ms after the mouse has stopped moving in which to show the tooltip */
export const TOOLTIP_DISPLAY_DELAY = 10
export const TOOLTIP_DISPLAY_DELAY = 60
/** The time in ms to debounce mouseover events. */
export const MOUSEOVER_DELAY = 50

View File

@ -1,7 +1,6 @@
import { hashCode } from './hashCode'
// TODOD #31952: Some of these tests are failing. They should be fixed and made to run in CI, or deleted.
describe.skip('hashCode', () => {
describe('hashCode', () => {
const testCaseUUIDs = {
'd3e406d5-a359-4b88-b0d3-db025a957811': 'EvvIjqiG1H71c2DNHbO4m2E/hvN2cYpGVRH+hcLW4uM=',
'd3f07658-2629-45ad-9159-86b738f0b6bf': 'k+mqeb0pK+eT3TbvrR2IEsyhty5NJHKNeNr9AdmlwMc=',

View File

@ -1,3 +1,6 @@
const { TextEncoder } = require('util')
const { Crypto } = require('@peculiar/webcrypto')
const JSDOMEnvironment = require('jest-environment-jsdom')
module.exports = class JSDOMEnvironmentGlobal extends JSDOMEnvironment {
@ -10,6 +13,18 @@ module.exports = class JSDOMEnvironmentGlobal extends JSDOMEnvironment {
// This does not implement href and target, which is impossible without mofifying JSDOM.
global.SVGAElement = class SVGAElement extends global.SVGGraphicsElement {}
if (typeof this.global.TextEncoder === 'undefined') {
// Polyfill is required until the issue below is resolved:
// https://github.com/facebook/jest/issues/9983
this.global.TextEncoder = TextEncoder
}
if (typeof this.global.crypto === 'undefined') {
// A separate polyfill is required until `crypto` is included into `jsdom`:
// https://github.com/jsdom/jsdom/issues/1612
this.global.crypto = new Crypto()
}
// jsdom doesn't support document.queryCommandSupported(), needed for monaco-editor.
// https://github.com/testing-library/react-testing-library/issues/546
// eslint-disable-next-line @typescript-eslint/unbound-method