From 4e45d35925f11a70fb11fa8e221acb37725e7eaf Mon Sep 17 00:00:00 2001 From: FoxxMD Date: Thu, 8 Feb 2024 11:47:58 -0500 Subject: [PATCH] test: Add test that handles no existing scrobble match with score greater than 0 #130 Detects track string error thrown reported via https://github.com/FoxxMD/multi-scrobbler/issues/130#issuecomment-1934452275 --- .../tests/scrobbler/scrobblers.test.ts | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/backend/tests/scrobbler/scrobblers.test.ts b/src/backend/tests/scrobbler/scrobblers.test.ts index 38ebddbd..29bab612 100644 --- a/src/backend/tests/scrobbler/scrobblers.test.ts +++ b/src/backend/tests/scrobbler/scrobblers.test.ts @@ -1,9 +1,12 @@ import {describe, it, after, before} from 'mocha'; -import {assert} from 'chai'; +import chai, {assert} from 'chai'; +import asPromised from 'chai-as-promised'; import clone from 'clone'; import pEvent from 'p-event'; import { http, HttpResponse } from 'msw'; +chai.use(asPromised); + import withDuration from '../plays/withDuration.json'; import mixedDuration from '../plays/mixedDuration.json'; @@ -111,6 +114,23 @@ describe('Detects duplicate and unique scrobbles from client recent history', fu assert.isFalse(await testScrobbler.alreadyScrobbled(newScrobble)); }); + + it('It handles unique detection when no existing scrobble matches above a score of 0', async function () { + + testScrobbler.recentScrobbles = normalizedWithMixedDur; + + const uniquePlay = generatePlay({ + artists: [ + "2814" + ], + track: "新宿ゴールデン街", + duration: 130, + playDate: normalizedWithMixedDur[normalizedWithMixedDur.length - 3].data.playDate.add(6, 'minutes') + }); + + await assert.isFulfilled( testScrobbler.alreadyScrobbled(uniquePlay)) + await assert.eventually.isFalse(testScrobbler.alreadyScrobbled(uniquePlay)) + }); }); describe('When scrobble track/artist/album matches existing but is a new scrobble', function () {