mirror of
https://github.com/FoxxMD/multi-scrobbler.git
synced 2026-07-09 17:28:28 +00:00
test: Setup transient di cache
This commit is contained in:
parent
78f4767dd2
commit
32e2aa6974
4 changed files with 19 additions and 7 deletions
|
|
@ -3,5 +3,8 @@
|
|||
"extension": "ts",
|
||||
"import": "tsx/esm",
|
||||
"spec": "./src/backend/tests/**/*.test.ts",
|
||||
"file": [
|
||||
"./src/backend/tests/setup.ts"
|
||||
],
|
||||
"exit": true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,11 @@ export class TestScrobbler extends AbstractScrobbleClient {
|
|||
return (await this.existingScrobble(playObj)) !== undefined;
|
||||
}
|
||||
|
||||
protected async doParseCache() {
|
||||
await this.cache.init();
|
||||
return super.doParseCache();
|
||||
}
|
||||
|
||||
|
||||
|
||||
playToClientPayload(playObject: PlayObject): object {
|
||||
|
|
|
|||
|
|
@ -8,16 +8,14 @@ import { http, HttpResponse } from 'msw';
|
|||
import pEvent from 'p-event';
|
||||
import { PlayObject } from "../../../core/Atomic.js";
|
||||
import { genGroupIdStr, sleep } from "../../utils.js";
|
||||
import mixedDuration from '../plays/mixedDuration.json';
|
||||
import withDuration from '../plays/withDuration.json';
|
||||
import mixedDuration from '../plays/mixedDuration.json' with { type: 'json' };
|
||||
import withDuration from '../plays/withDuration.json' with { type: 'json' };
|
||||
import { MockNetworkError, withRequestInterception } from "../utils/networking.js";
|
||||
import { asPlays, generatePlay, generatePlayPlatformId, generatePlays, normalizePlays } from "../utils/PlayTestUtils.js";
|
||||
import MockDate from 'mockdate';
|
||||
|
||||
import { NowPlayingScrobbler, TestAuthScrobbler, TestScrobbler } from "./TestScrobbler.js";
|
||||
import { PlayPlatformId } from '../../common/infrastructure/Atomic.js';
|
||||
import { getRoot } from '../../ioc.js';
|
||||
import { loggerTest } from '@foxxmd/logging';
|
||||
|
||||
chai.use(asPromised);
|
||||
|
||||
|
|
@ -31,8 +29,6 @@ const normalizedWithMixedDur = normalizePlays(mixedDurPlays, {initialDate: first
|
|||
|
||||
const normalizedWithMixedDurOlder = normalizePlays(mixedDurPlays, {initialDate: olderFirstPlayDate});
|
||||
|
||||
getRoot({cache: {scrobble: {provider: 'memory'}}, logger: loggerTest});
|
||||
|
||||
const generateTestScrobbler = () => {
|
||||
const testScrobbler = new TestScrobbler();
|
||||
testScrobbler.verboseOptions = {
|
||||
|
|
@ -665,7 +661,7 @@ describe('Scrobble client uses transform plays correctly', function() {
|
|||
|
||||
describe('Manages scrobble queue', function() {
|
||||
|
||||
before(async function() {
|
||||
beforeEach(async function() {
|
||||
testScrobbler = generateTestScrobbler();
|
||||
await testScrobbler.initialize();
|
||||
testScrobbler.recentScrobbles = normalizedWithMixedDur;
|
||||
|
|
|
|||
8
src/backend/tests/setup.ts
Normal file
8
src/backend/tests/setup.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import { loggerTest } from '@foxxmd/logging';
|
||||
import { getRoot } from "../ioc.js";
|
||||
import { MSCache } from '../common/Cache.js';
|
||||
|
||||
const transientCache = () => new MSCache(loggerTest, {scrobble: {provider: 'memory'}});
|
||||
|
||||
const root = getRoot({cache: transientCache, logger: loggerTest});
|
||||
root.items.cache().init();
|
||||
Loading…
Add table
Add a link
Reference in a new issue