diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-18 16:43:55 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-18 16:43:55 +0100 |
| commit | 6275aa8a064c433e5130e51268b4d937ccf2b631 (patch) | |
| tree | 2504eca3247a28a4c86dd8c5d080d6f7e0b1ac02 /tests | |
| parent | 0480dc62af2be80a17b98d88108cb04d7280a3bf (diff) | |
| download | deck-it-6275aa8a064c433e5130e51268b4d937ccf2b631.tar.gz deck-it-6275aa8a064c433e5130e51268b4d937ccf2b631.zip | |
feat(dashboard): the music card shows the game being played
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_music.mjs | 35 |
1 files changed, 35 insertions, 0 deletions
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. <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"; +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"); |
