Files
misskey/packages/frontend/test/unit/scroll.test.ts
T
かっこかり 9472e72678 enhance(frontend/test): frontend e2eをPlaywrightに移行 (#17682)
* enhance(frontend/test): frontend e2eをVitest Browser Modeに移行

* fix

* fix unit tests

* fix

* fix

* update playwright

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* perf

* Revert "perf"

This reverts commit e60e965c3c.

* fix
2026-07-08 20:58:02 +09:00

67 lines
1.8 KiB
TypeScript

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { describe, test, assert, afterEach } from 'vitest';
import { Window } from 'happy-dom';
import { onScrollBottom, onScrollTop } from '@@/js/scroll.js';
describe('Scroll', () => {
describe('onScrollTop', () => {
/* 動作しない(happy-domのバグ?)
test('Initial onScrollTop callback for connected elements', () => {
const { document } = new Window();
const div = window.document.createElement('div');
assert.strictEqual(div.scrollTop, 0);
window.document.body.append(div);
let called = false;
onScrollTop(div as any as HTMLElement, () => called = true);
assert.ok(called);
});
*/
test('No onScrollTop callback for disconnected elements', () => {
const { document: _ } = new Window();
const div = window.document.createElement('div');
assert.strictEqual(div.scrollTop, 0);
let called = false;
onScrollTop(div as any as HTMLElement, () => called = true);
assert.ok(!called);
});
});
describe('onScrollBottom', () => {
/* 動作しない(happy-domのバグ?)
test('Initial onScrollBottom callback for connected elements', () => {
const { document } = new Window();
const div = window.document.createElement('div');
assert.strictEqual(div.scrollTop, 0);
window.document.body.append(div);
let called = false;
onScrollBottom(div as any as HTMLElement, () => called = true);
assert.ok(called);
});
*/
test('No onScrollBottom callback for disconnected elements', () => {
const { document: _ } = new Window();
const div = window.document.createElement('div');
assert.strictEqual(div.scrollTop, 0);
let called = false;
onScrollBottom(div as any as HTMLElement, () => called = true);
assert.ok(!called);
});
});
});