33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
|
|
// Simulation of song objects
|
|
const songs = [
|
|
{ name: "Server Song", id: 123, hash: "hash123" },
|
|
{ name: "Custom Song (No ID)", id: undefined, hash: "hashCustom" },
|
|
{ name: "Custom Song (Null ID)", id: null, hash: "hashNull" },
|
|
{ name: "Edge Case (ID 0)", id: 0, hash: "hashZero" } // Checking if behavior is acceptable
|
|
];
|
|
|
|
console.log("=== Frontend Logic Test: Song ID Fallback ===");
|
|
|
|
songs.forEach(song => {
|
|
// Logic from scoresheet.js / songselect.js
|
|
const songId = song.id || song.hash;
|
|
|
|
console.log(`Song: ${song.name}`);
|
|
console.log(` Raw ID: ${song.id}, Hash: ${song.hash}`);
|
|
console.log(` Resolved songId: ${songId}`);
|
|
|
|
if (song.id && songId === song.id) {
|
|
console.log(" ✅ Correctly used ID");
|
|
} else if (!song.id && songId === song.hash) {
|
|
console.log(" ✅ Correctly fell back to Hash");
|
|
} else if (song.id === 0 && songId === song.hash) {
|
|
console.log(" ⚠️ ID was 0, used Hash. (Acceptable if ID > 0 always)");
|
|
} else {
|
|
console.log(" ❌ FAILED logic mismatch");
|
|
}
|
|
console.log("---");
|
|
});
|
|
|
|
console.log("Tests Completed.");
|