Skip to content

Commit 3c0c257

Browse files
committed
Fixed failing unit tests
1 parent 3ae3794 commit 3c0c257

5 files changed

Lines changed: 18 additions & 3 deletions

File tree

jest.setup.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { performance } from 'perf_hooks';
44
import 'jest-canvas-mock';
55
import './__mocks__/dh-core';
66
import Log from '@deephaven/log';
7+
import { TestUtils } from '@deephaven/utils';
78

89
let logLevel = parseInt(process.env.DH_LOG_LEVEL ?? '', 10);
910
if (!Number.isFinite(logLevel)) {
@@ -34,6 +35,13 @@ Object.defineProperty(window, 'matchMedia', {
3435

3536
Object.defineProperty(window, 'performance', {
3637
value: performance,
38+
writable: true,
39+
});
40+
41+
Object.defineProperty(window, 'ResizeObserver', {
42+
value: function () {
43+
return TestUtils.createMockProxy<ResizeObserver>();
44+
},
3745
});
3846

3947
Object.defineProperty(window, 'TextDecoder', {

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"@deephaven/redux": "file:../redux",
7070
"@deephaven/stylelint-config": "file:../stylelint-config",
7171
"@deephaven/tsconfig": "file:../tsconfig",
72+
"@deephaven/utils": "file:../utils",
7273
"@fortawesome/fontawesome-common-types": "^6.1.1",
7374
"@playwright/test": "^1.30.0",
7475
"@testing-library/jest-dom": "^5.16.4",

packages/console/src/monaco/MonacoUtils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ describe('disableKeyBindings', () => {
173173

174174
keybindingsList.forEach(keybindings => {
175175
expect(editor.addAction).toHaveBeenCalledWith({
176-
id: expect.stringMatching(/^disable-keybindings-[^-]+/),
176+
id: expect.stringMatching(/^disable-keybindings-.+/),
177177
label: '',
178178
keybindings,
179179
run: expect.any(Function),

packages/iris-grid/src/sidebar/CustomColumnBuilder.test.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ test('Calls on save', async () => {
4545
});
4646

4747
test('Switches to loader button while saving', async () => {
48-
jest.useFakeTimers();
48+
jest.useFakeTimers({
49+
// Monaco seems to make some call to performance.mark(), so we need to leave it in-tact
50+
doNotFake: ['performance'],
51+
});
4952
const user = userEvent.setup({ delay: null });
5053
const model = irisGridTestUtils.makeModel();
5154
const mockSave = jest.fn(() =>
@@ -100,7 +103,9 @@ test('Ignores deleted formulas on save', async () => {
100103
// There is an issue with populating the custom columns and then editing the existing column
101104
// RTL/monaco aren't playing nicely and it won't edit the existing text
102105
// This test instead creates the new text, saves, then removes it to test the same behavior
103-
jest.useFakeTimers();
106+
jest.useFakeTimers({
107+
doNotFake: ['performance'], // Monaco seems to make some call to performance.mark(), so we need to leave it in-tact
108+
});
104109
const user = userEvent.setup({ delay: null });
105110
const model = irisGridTestUtils.makeModel();
106111
const mockSave = jest.fn(() =>

0 commit comments

Comments
 (0)