Skip to content

Commit

Permalink
test: Add test that handles no existing scrobble match with score gre…
Browse files Browse the repository at this point in the history
…ater than 0 #130

Detects track string error thrown reported via #130 (comment)
  • Loading branch information
FoxxMD committed Feb 8, 2024
1 parent c76d482 commit 4e45d35
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/backend/tests/scrobbler/scrobblers.test.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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 () {
Expand Down

0 comments on commit 4e45d35

Please sign in to comment.