// deck-it - node checks for the music card's game pick // Copyright (C) 2026 Danilo M. // // 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"; import { pickGame, hours } from "../static/modules/music.js"; const pc = { playing: { platform: "steam", name: "Worms", cover: null, minutes: 5, session: 100 } }; const xbox = { playing: { id: "7", name: "Forza" }, session: 200, titles: [{ id: "7", cover: "https://x/c.png", minutes: 90 }] }; assert.equal(pickGame(null, null), null); assert.equal(pickGame({ playing: null }, { playing: null }), null); assert.deepEqual(pickGame(pc, xbox), pc.playing); assert.deepEqual(pickGame({ playing: null }, xbox), { platform: "xbox", name: "Forza", cover: "https://x/c.png", minutes: 90, session: 200 }); assert.deepEqual(pickGame(undefined, { playing: { id: "8", name: "New" }, session: 1 }), { platform: "xbox", name: "New", cover: null, minutes: null, session: 1 }); assert.equal(hours(0), "0m"); assert.equal(hours(59), "59m"); assert.equal(hours(125), "2h 05m"); console.log("music ok");