test(unit): add fixes for newer jest

This commit is contained in:
Christopher Willis-Ford 2024-02-26 16:13:36 -08:00
parent edb224c53a
commit 32b839a0d6
3 changed files with 11 additions and 1 deletions

View file

@ -177,6 +177,7 @@ describe('Compose Comment test', () => {
test('Comment Status initialized properly when muted', () => {
jest.useFakeTimers();
jest.spyOn(global, 'setTimeout');
const realDateNow = Date.now.bind(global.Date);
global.Date.now = () => 0;
const mutedStore = mockStore({

View file

@ -12,6 +12,8 @@ describe('Navigation', () => {
beforeEach(() => {
store = null;
jest.useFakeTimers();
jest.spyOn(global, 'setTimeout');
jest.spyOn(global, 'clearTimeout');
});
const getNavigationWrapper = props => {

View file

@ -13,9 +13,16 @@ const {
describe('unit test lib/validate.js', () => {
const realLocation = global.window.location;
beforeEach(() => {
// mock window navigation
global.window.location.assign = jest.fn();
// see https://stackoverflow.com/q/46169824
delete global.window.location;
global.window.location = {
...realLocation,
assign: jest.fn()
};
});
test('initialState', () => {