Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/vitest/stubs/providers/InMemory.FsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import FsProvider from '../../../../src/providers/generic/file/FsProvider';
import StatInterface from '../../../../src/providers/generic/file/StatInterface';
import * as path from 'path';

type FileType = {name: string, type: "FILE" | "DIR", nodes: FileType[] | undefined, content: string | undefined, mtime: Date};
type FileType = {name: string, type: "FILE" | "DIR", nodes: FileType[] | undefined, content: string | Buffer | undefined, mtime: Date};


/**
Expand Down
2 changes: 1 addition & 1 deletion test/vitest/stubs/providers/stub.InteractionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class StubInteractionProvider extends InteractionProvider {
throw new Error("Stub access must be mocked or spied");
}

async getEnvironmentVariables(): Promise<string[]> {
async getEnvironmentVariables(): Promise<Record<string, string>> {
throw new Error("Stub access must be mocked or spied");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ vi.mock('../../../../../src/assets/data/ecosystemJsonSchema.json', () => ({
get default() { return mockJsonSchema; }
}));

import type {ThunderstoreEcosystem} from '../../../../../src/assets/data/ecosystemTypes';
import type {R2Modman, ThunderstoreEcosystem} from '../../../../../src/assets/data/ecosystemTypes';
import {VersionedThunderstoreEcosystem, updateEcosystemReactives, updateLatestEcosystemSchema} from '../../../../../src/r2mm/ecosystem/EcosystemSchema';
import {EcosystemModloaderPackages, EcosystemSupportedGames} from '../../../../../src/model/schema/ThunderstoreSchema';
import {MODLOADER_PACKAGES, MOD_LOADER_VARIANTS, updateModLoaderExports} from '../../../../../src/r2mm/installing/profile_installers/ModLoaderVariantRecord';
Expand Down Expand Up @@ -245,13 +245,14 @@ describe('EcosystemSchema', () => {
});

test('populates games from cache into reactives when fetch fails with existing cache', async () => {
const r2Field = [{ meta: { iconUrl: null } }] as R2Modman[];
await writeCacheFile({
games: {
'test-cached-game': {
distributions: [],
label: 'Test Cached Game',
meta: { displayName: 'Test Cached Game', iconUrl: null },
r2modman: [{ meta: { iconUrl: null } }],
r2modman: r2Field,
uuid: 'test-uuid',
},
},
Expand Down
34 changes: 17 additions & 17 deletions test/vitest/tests/utils/utils.ArrayUtils.ts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,40 +29,40 @@ describe("ArrayUtils.chunk", () => {
const actual1 = chunk([1, 2, 3, 4], 1);
expect(Array.isArray(actual1)).toBeTruthy();
expect(actual1.length).toStrictEqual(4);
expect(actual1[0][0]).toStrictEqual(1);
expect(actual1[1][0]).toStrictEqual(2);
expect(actual1[2][0]).toStrictEqual(3);
expect(actual1[3][0]).toStrictEqual(4);
expect(actual1[0]![0]).toStrictEqual(1);
expect(actual1[1]![0]).toStrictEqual(2);
expect(actual1[2]![0]).toStrictEqual(3);
expect(actual1[3]![0]).toStrictEqual(4);

const actual2 = chunk(["a", "b", "c", "d"], 2);
expect(Array.isArray(actual2)).toBeTruthy();
expect(actual2.length).toStrictEqual(2);
expect(actual2[0][0]).toStrictEqual("a");
expect(actual2[0][1]).toStrictEqual("b");
expect(actual2[1][0]).toStrictEqual("c");
expect(actual2[1][1]).toStrictEqual("d");
expect(actual2[0]![0]).toStrictEqual("a");
expect(actual2[0]![1]).toStrictEqual("b");
expect(actual2[1]![0]).toStrictEqual("c");
expect(actual2[1]![1]).toStrictEqual("d");

const actual3 = chunk([{x: 1}, {x: "a"}, {x: () => null}, {x: []}], 4);
expect(Array.isArray(actual3)).toBeTruthy();
expect(actual3.length).toStrictEqual(1);
expect(actual3[0][0]["x"]).toStrictEqual(1);
expect(actual3[0][1]["x"]).toStrictEqual("a");
expect(typeof actual3[0][2]["x"]).toStrictEqual("function");
expect(Array.isArray(actual3[0][3]["x"])).toBeTruthy();
expect(actual3[0]![0]!["x"]).toStrictEqual(1);
expect(actual3[0]![1]!["x"]).toStrictEqual("a");
expect(typeof actual3[0]![2]!["x"]).toStrictEqual("function");
expect(Array.isArray(actual3[0]![3]!["x"])).toBeTruthy();
});

test("Chunks arrays with orphans", () => {
const actual1 = chunk([1, 2, 3], 2);
expect(Array.isArray(actual1)).toBeTruthy();
expect(actual1.length).toStrictEqual(2);
expect(actual1[0].length).toStrictEqual(2);
expect(actual1[1].length).toStrictEqual(1);
expect(actual1[0]!.length).toStrictEqual(2);
expect(actual1[1]!.length).toStrictEqual(1);

const actual2 = chunk([1, 2, 3, "a", "b", "c", 4, 5], 3);
expect(Array.isArray(actual2)).toBeTruthy();
expect(actual2.length).toStrictEqual(3);
expect(actual2[0].length).toStrictEqual(3);
expect(actual2[1].length).toStrictEqual(3);
expect(actual2[2].length).toStrictEqual(2);
expect(actual2[0]!.length).toStrictEqual(3);
expect(actual2[1]!.length).toStrictEqual(3);
expect(actual2[2]!.length).toStrictEqual(2);
});
});
4 changes: 2 additions & 2 deletions test/vitest/tests/utils/utils.DependencyUtils.ts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ function addMockPackage(modData: {

// Use original, unsorted arguments to return the first version passed in.
const version = new ThunderstoreVersion();
const versionStr = modData.versions[0].version;
const versionStr = modData.versions[0]!.version;
version.setVersionNumber(new VersionNumber(versionStr));
version.setName(`${data.full_name}-${versionStr}`);
version.setDependencies(modData.versions[0].dependencies || []);
version.setDependencies(modData.versions[0]!.dependencies || []);
firstCombo.setVersion(version);

return firstCombo;
Expand Down
2 changes: 1 addition & 1 deletion test/vitest/utils/ObjectTestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default class ObjectTestUtils {

public static lazyClone<T>(copy: T): T {
const obj: any = {};
Object.keys(copy).forEach((key: any) => {
Object.keys(copy as object).forEach((key: any) => {
obj[key] = (copy as any)[key];
});
return obj as unknown as T;
Expand Down
Loading