diff options
Diffstat (limited to 'tests/test_windows.mjs')
| -rw-r--r-- | tests/test_windows.mjs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_windows.mjs b/tests/test_windows.mjs new file mode 100644 index 0000000..534fd45 --- /dev/null +++ b/tests/test_windows.mjs @@ -0,0 +1,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); |
