fix: chat scroll fix
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { resolveAutoScrollBehavior } from './auto-scroll.rules';
|
||||
import { isStuckToBottom, resolveAutoScrollBehavior } from './auto-scroll.rules';
|
||||
|
||||
describe('resolveAutoScrollBehavior', () => {
|
||||
const base = {
|
||||
@@ -48,3 +48,28 @@ describe('resolveAutoScrollBehavior', () => {
|
||||
).toBe('smooth');
|
||||
});
|
||||
});
|
||||
|
||||
describe('isStuckToBottom', () => {
|
||||
it('is stuck when exactly at the bottom', () => {
|
||||
expect(isStuckToBottom(0)).toBe(true);
|
||||
});
|
||||
|
||||
it('is stuck within the default sticky threshold', () => {
|
||||
expect(isStuckToBottom(300)).toBe(true);
|
||||
expect(isStuckToBottom(299)).toBe(true);
|
||||
});
|
||||
|
||||
it('is not stuck once past the default threshold', () => {
|
||||
expect(isStuckToBottom(301)).toBe(false);
|
||||
expect(isStuckToBottom(2000)).toBe(false);
|
||||
});
|
||||
|
||||
it('honours a custom threshold', () => {
|
||||
expect(isStuckToBottom(80, 100)).toBe(true);
|
||||
expect(isStuckToBottom(150, 100)).toBe(false);
|
||||
});
|
||||
|
||||
it('treats negative overscroll distances as stuck', () => {
|
||||
expect(isStuckToBottom(-20)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user