From 6275aa8a064c433e5130e51268b4d937ccf2b631 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 18 Nov 2026 16:43:55 +0100 Subject: feat(dashboard): the music card shows the game being played Co-Authored-By: Claude Opus 5.5 --- tests/test_music.mjs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/test_music.mjs (limited to 'tests') diff --git a/tests/test_music.mjs b/tests/test_music.mjs new file mode 100644 index 0000000..0fb8ddd --- /dev/null +++ b/tests/test_music.mjs @@ -0,0 +1,35 @@ +// 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"); -- cgit v1.2.3