42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { describe, expect, test } from 'bun:test';
|
|||
|
|
|
||
|
|
import { shouldAutoLoadEarlierForUnderfilledPinnedViewport } from './useChatTimelineController';
|
||
|
|
|
||
|
|
const baseInput = {
|
||
|
|
sessionId: 'ses_1',
|
||
|
|
isPinned: true,
|
||
|
|
canLoadEarlier: true,
|
||
|
|
isLoadingOlder: false,
|
||
|
|
pendingRevealWork: false,
|
||
|
|
scrollHeight: 799,
|
||
|
|
clientHeight: 800,
|
||
|
|
};
|
||
|
|
|
||
|
|
describe('shouldAutoLoadEarlierForUnderfilledPinnedViewport', () => {
|
||
|
|
test('loads when pinned content does not fill the viewport', () => {
|
||
|
|
expect(shouldAutoLoadEarlierForUnderfilledPinnedViewport(baseInput)).toBe(true);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('does not load when content already overflows', () => {
|
||
|
|
expect(shouldAutoLoadEarlierForUnderfilledPinnedViewport({
|
||
|
|
...baseInput,
|
||
|
|
scrollHeight: 802,
|
||
|
|
})).toBe(false);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('does not load while user is away from bottom or history work is active', () => {
|
||
|
|
expect(shouldAutoLoadEarlierForUnderfilledPinnedViewport({
|
||
|
|
...baseInput,
|
||
|
|
isPinned: false,
|
||
|
|
})).toBe(false);
|
||
|
|
expect(shouldAutoLoadEarlierForUnderfilledPinnedViewport({
|
||
|
|
...baseInput,
|
||
|
|
isLoadingOlder: true,
|
||
|
|
})).toBe(false);
|
||
|
|
expect(shouldAutoLoadEarlierForUnderfilledPinnedViewport({
|
||
|
|
...baseInput,
|
||
|
|
pendingRevealWork: true,
|
||
|
|
})).toBe(false);
|
||
|
|
});
|
||
|
|
});
|