1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
// deck-it - check for static/modules/windows.js: `node tests/test_windows.mjs`
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import assert from "node:assert/strict";
globalThis.document = { addEventListener() {} }; // the module wires a listener on load
const { default: windows } = await import("../static/modules/windows.js");
const st = (...ids) => ({ windows: ids.map((id) => ({ id })), peek: 5 });
assert.equal(windows.peek(st("a", "b")), 0); // first poll only learns
assert.equal(windows.peek(st("a", "b")), 0);
assert.equal(windows.peek(st("a")), 0); // a close is not news
assert.equal(windows.peek(st("a", "c")), 5); // a new window is, for [windows] peek seconds
assert.equal(windows.peek({ error: "x" }), false); // an error keeps what it knew
assert.equal(windows.peek(st("a", "c")), 0);
|