|
|
|
|
@ -3,7 +3,6 @@ import { renderHook } from '@testing-library/react-hooks'; |
|
|
|
|
|
|
|
|
|
import { createRenteionPolicySettingsMock as createMock } from '../../tests/mocks/client/mockRetentionPolicySettings'; |
|
|
|
|
import { createFakeRoom } from '../../tests/mocks/data'; |
|
|
|
|
import { setDate } from '../../tests/mocks/mockDate'; |
|
|
|
|
import { usePruneWarningMessage } from './usePruneWarningMessage'; |
|
|
|
|
|
|
|
|
|
jest.useFakeTimers(); |
|
|
|
|
@ -22,10 +21,13 @@ const getRetentionRoomProps = (props: Partial<IRoomWithRetentionPolicy['retentio |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
beforeEach(() => { |
|
|
|
|
jest.setSystemTime(new Date(2024, 5, 1, 0, 0, 0)); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('usePruneWarningMessage hook', () => { |
|
|
|
|
describe('Cron timer and precision', () => { |
|
|
|
|
it('Should update the message after the nextRunDate has passaed', async () => { |
|
|
|
|
setDate(); |
|
|
|
|
const fakeRoom = createFakeRoom({ t: 'c' }); |
|
|
|
|
const { result } = renderHook(() => usePruneWarningMessage(fakeRoom), { |
|
|
|
|
wrapper: createMock({ |
|
|
|
|
@ -40,7 +42,6 @@ describe('usePruneWarningMessage hook', () => { |
|
|
|
|
|
|
|
|
|
it('Should return the default warning with precision set to every_hour', () => { |
|
|
|
|
const fakeRoom = createFakeRoom({ t: 'c' }); |
|
|
|
|
setDate(); |
|
|
|
|
const { result } = renderHook(() => usePruneWarningMessage(fakeRoom), { |
|
|
|
|
wrapper: createMock({ |
|
|
|
|
appliesToChannels: true, |
|
|
|
|
@ -53,7 +54,6 @@ describe('usePruneWarningMessage hook', () => { |
|
|
|
|
|
|
|
|
|
it('Should return the default warning with precision set to every_six_hours', () => { |
|
|
|
|
const fakeRoom = createFakeRoom({ t: 'c' }); |
|
|
|
|
setDate(); |
|
|
|
|
const { result } = renderHook(() => usePruneWarningMessage(fakeRoom), { |
|
|
|
|
wrapper: createMock({ |
|
|
|
|
appliesToChannels: true, |
|
|
|
|
@ -66,7 +66,6 @@ describe('usePruneWarningMessage hook', () => { |
|
|
|
|
|
|
|
|
|
it('Should return the default warning with precision set to every_day', () => { |
|
|
|
|
const fakeRoom = createFakeRoom({ t: 'c' }); |
|
|
|
|
setDate(); |
|
|
|
|
const { result } = renderHook(() => usePruneWarningMessage(fakeRoom), { |
|
|
|
|
wrapper: createMock({ |
|
|
|
|
appliesToChannels: true, |
|
|
|
|
@ -79,7 +78,6 @@ describe('usePruneWarningMessage hook', () => { |
|
|
|
|
|
|
|
|
|
it('Should return the default warning with advanced precision', () => { |
|
|
|
|
const fakeRoom = createFakeRoom({ t: 'c' }); |
|
|
|
|
setDate(); |
|
|
|
|
const { result } = renderHook(() => usePruneWarningMessage(fakeRoom), { |
|
|
|
|
wrapper: createMock({ |
|
|
|
|
appliesToChannels: true, |
|
|
|
|
@ -95,7 +93,6 @@ describe('usePruneWarningMessage hook', () => { |
|
|
|
|
describe('No override', () => { |
|
|
|
|
it('Should return the default warning', () => { |
|
|
|
|
const fakeRoom = createFakeRoom({ t: 'c' }); |
|
|
|
|
setDate(); |
|
|
|
|
const { result } = renderHook(() => usePruneWarningMessage(fakeRoom), { |
|
|
|
|
wrapper: createMock({ |
|
|
|
|
appliesToChannels: true, |
|
|
|
|
@ -107,7 +104,6 @@ describe('usePruneWarningMessage hook', () => { |
|
|
|
|
|
|
|
|
|
it('Should return the unpinned messages warning', () => { |
|
|
|
|
const fakeRoom = createFakeRoom({ t: 'c' }); |
|
|
|
|
setDate(); |
|
|
|
|
const { result } = renderHook(() => usePruneWarningMessage(fakeRoom), { |
|
|
|
|
wrapper: createMock({ |
|
|
|
|
appliesToChannels: true, |
|
|
|
|
@ -120,7 +116,6 @@ describe('usePruneWarningMessage hook', () => { |
|
|
|
|
|
|
|
|
|
it('Should return the files only warning', () => { |
|
|
|
|
const fakeRoom = createFakeRoom({ t: 'c' }); |
|
|
|
|
setDate(); |
|
|
|
|
|
|
|
|
|
const { result } = renderHook(() => usePruneWarningMessage(fakeRoom), { |
|
|
|
|
wrapper: createMock({ |
|
|
|
|
@ -134,7 +129,6 @@ describe('usePruneWarningMessage hook', () => { |
|
|
|
|
|
|
|
|
|
it('Should return the unpinned files only warning', () => { |
|
|
|
|
const fakeRoom = createFakeRoom({ t: 'c' }); |
|
|
|
|
setDate(); |
|
|
|
|
|
|
|
|
|
const { result } = renderHook(() => usePruneWarningMessage(fakeRoom), { |
|
|
|
|
wrapper: createMock({ |
|
|
|
|
@ -151,7 +145,6 @@ describe('usePruneWarningMessage hook', () => { |
|
|
|
|
describe('Overriden', () => { |
|
|
|
|
it('Should return the default warning', () => { |
|
|
|
|
const fakeRoom = createFakeRoom({ t: 'p', ...getRetentionRoomProps() }); |
|
|
|
|
setDate(); |
|
|
|
|
const { result } = renderHook(() => usePruneWarningMessage(fakeRoom), { |
|
|
|
|
wrapper: createMock(), |
|
|
|
|
}); |
|
|
|
|
@ -160,7 +153,6 @@ describe('usePruneWarningMessage hook', () => { |
|
|
|
|
|
|
|
|
|
it('Should return the unpinned messages warning', () => { |
|
|
|
|
const fakeRoom = createFakeRoom({ t: 'p', ...getRetentionRoomProps({ excludePinned: true }) }); |
|
|
|
|
setDate(); |
|
|
|
|
const { result } = renderHook(() => usePruneWarningMessage(fakeRoom), { |
|
|
|
|
wrapper: createMock(), |
|
|
|
|
}); |
|
|
|
|
@ -169,7 +161,6 @@ describe('usePruneWarningMessage hook', () => { |
|
|
|
|
|
|
|
|
|
it('Should return the files only warning', () => { |
|
|
|
|
const fakeRoom = createFakeRoom({ t: 'p', ...getRetentionRoomProps({ filesOnly: true }) }); |
|
|
|
|
setDate(); |
|
|
|
|
|
|
|
|
|
const { result } = renderHook(() => usePruneWarningMessage(fakeRoom), { |
|
|
|
|
wrapper: createMock(), |
|
|
|
|
@ -179,7 +170,6 @@ describe('usePruneWarningMessage hook', () => { |
|
|
|
|
|
|
|
|
|
it('Should return the unpinned files only warning', () => { |
|
|
|
|
const fakeRoom = createFakeRoom({ t: 'p', ...getRetentionRoomProps({ excludePinned: true, filesOnly: true }) }); |
|
|
|
|
setDate(); |
|
|
|
|
|
|
|
|
|
const { result } = renderHook(() => usePruneWarningMessage(fakeRoom), { |
|
|
|
|
wrapper: createMock(), |
|
|
|
|
|