Skip to content

Commit

Permalink
Rename ThunderstorePackages to Deprecations
Browse files Browse the repository at this point in the history
All remaining code deals with calculating the deprecation status of
packages based on the status of their dependencies, so the new name is
more descriptive.

The methods remain wrapped in a class to make it easier to spy on them
in Jest test cases.
  • Loading branch information
anttimaki committed Mar 19, 2024
1 parent 3f3f058 commit d9b89a7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/store/modules/TsModsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ThunderstoreCombo from '../../model/ThunderstoreCombo';
import ThunderstoreMod from '../../model/ThunderstoreMod';
import ConnectionProvider from '../../providers/generic/connection/ConnectionProvider';
import * as PackageDb from '../../r2mm/manager/PackageDexieStore';
import ThunderstorePackages from '../../r2mm/data/ThunderstorePackages';
import { Deprecations } from '../../utils/Deprecations';

interface CachedMod {
tsMod: ThunderstoreMod | undefined;
Expand Down Expand Up @@ -126,7 +126,7 @@ export const TsModsModule = {
state.exclusions = payload;
},
updateDeprecated(state, allMods: ThunderstoreMod[]) {
state.deprecated = ThunderstorePackages.getDeprecatedPackageMap(allMods);
state.deprecated = Deprecations.getDeprecatedPackageMap(allMods);
}
},

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ThunderstoreMod from '../../model/ThunderstoreMod';
import ThunderstoreMod from '../model/ThunderstoreMod';

export default class ThunderstorePackages {
export class Deprecations {

public static getDeprecatedPackageMap(packages: ThunderstoreMod[]): Map<string, boolean> {
const packageMap = packages.reduce((map, pkg) => {
Expand Down
26 changes: 13 additions & 13 deletions test/jest/__tests__/utils/utils.getDeprecatedPackageMap.ts.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import ThunderstoreMod from "../../../../src/model/ThunderstoreMod";
import ThunderstoreVersion from "../../../../src/model/ThunderstoreVersion";
import ThunderstorePackages from "../../../../src/r2mm/data/ThunderstorePackages";
import { Deprecations } from "../../../../src/utils/Deprecations";

describe("ThunderstorePackages.getDeprecatedPackageMap", () => {
describe("Deprecations.getDeprecatedPackageMap", () => {
let spyedPopulator: jest.SpyInstance;

beforeEach(() => {
spyedPopulator = jest.spyOn(ThunderstorePackages, '_populateDeprecatedPackageMapForModChain');
spyedPopulator = jest.spyOn(Deprecations, '_populateDeprecatedPackageMapForModChain');
});

afterEach(() => {
Expand All @@ -21,7 +21,7 @@ describe("ThunderstorePackages.getDeprecatedPackageMap", () => {
createStubMod('TeamC-Mod1')
];

const actual = ThunderstorePackages.getDeprecatedPackageMap(mods);
const actual = Deprecations.getDeprecatedPackageMap(mods);

expect(actual.size).toBe(4);
expect(actual.get('TeamA-Mod1')).toStrictEqual(false);
Expand All @@ -38,7 +38,7 @@ describe("ThunderstorePackages.getDeprecatedPackageMap", () => {
createStubMod('TeamC-Mod1')
];

const actual = ThunderstorePackages.getDeprecatedPackageMap(mods);
const actual = Deprecations.getDeprecatedPackageMap(mods);

expect(actual.size).toBe(4);
expect(actual.get('TeamA-Mod1')).toStrictEqual(true);
Expand All @@ -53,7 +53,7 @@ describe("ThunderstorePackages.getDeprecatedPackageMap", () => {
createStubMod('Degrec-Alfie_Other_Knee', false, ['Degrec-Alfie_Knee']),
];

const actual = ThunderstorePackages.getDeprecatedPackageMap(mods);
const actual = Deprecations.getDeprecatedPackageMap(mods);

expect(actual.size).toBe(2);
expect(actual.get('Degrec-Alfie_Knee')).toStrictEqual(false);
Expand All @@ -67,7 +67,7 @@ describe("ThunderstorePackages.getDeprecatedPackageMap", () => {
createStubMod('Loop1-Mod3', false, ['Loop1-Mod1']),
];

const actual = ThunderstorePackages.getDeprecatedPackageMap(mods);
const actual = Deprecations.getDeprecatedPackageMap(mods);

expect(actual.size).toBe(3);
expect(actual.get('Loop1-Mod1')).toStrictEqual(false);
Expand All @@ -83,7 +83,7 @@ describe("ThunderstorePackages.getDeprecatedPackageMap", () => {
createStubMod('Loop2-Mod4', false, ['Loop2-Mod2']),
];

const actual = ThunderstorePackages.getDeprecatedPackageMap(mods);
const actual = Deprecations.getDeprecatedPackageMap(mods);

expect(actual.size).toBe(4);
expect(actual.get('Loop2-Mod1')).toStrictEqual(true);
Expand All @@ -102,7 +102,7 @@ describe("ThunderstorePackages.getDeprecatedPackageMap", () => {
createStubMod('X-ChainBottom'),
];

const actual = ThunderstorePackages.getDeprecatedPackageMap(mods);
const actual = Deprecations.getDeprecatedPackageMap(mods);

// Each mod causes one call due to for-loop (6 calls).
// Root1 causes three recursive calls down the chain (total 9 calls).
Expand All @@ -129,7 +129,7 @@ describe("ThunderstorePackages.getDeprecatedPackageMap", () => {
createStubMod('X-Root3', false, ['X-ChainTop']),
];

const actual = ThunderstorePackages.getDeprecatedPackageMap(mods);
const actual = Deprecations.getDeprecatedPackageMap(mods);

// Each mod causes one call due to for-loop (6 calls).
// Excluding ChainBottom, each mod should recursively call their
Expand All @@ -154,7 +154,7 @@ describe("ThunderstorePackages.getDeprecatedPackageMap", () => {
createStubMod('X-ChainBottom'),
];

const actual = ThunderstorePackages.getDeprecatedPackageMap(mods);
const actual = Deprecations.getDeprecatedPackageMap(mods);

// Each mod causes one call due to for-loop (6 calls).
// Each root mod recursively calls X-ChainTop, but the chain is
Expand All @@ -180,7 +180,7 @@ describe("ThunderstorePackages.getDeprecatedPackageMap", () => {
createStubMod('X-Root3', false, ['X-ChainTop']),
];

const actual = ThunderstorePackages.getDeprecatedPackageMap(mods);
const actual = Deprecations.getDeprecatedPackageMap(mods);

// Each mod causes one call due to for-loop (6 calls).
// Each mod recursively calls it's direct dependency, except for
Expand All @@ -202,7 +202,7 @@ describe("ThunderstorePackages.getDeprecatedPackageMap", () => {
createStubMod('Known-Mod2'),
];

const actual = ThunderstorePackages.getDeprecatedPackageMap(mods);
const actual = Deprecations.getDeprecatedPackageMap(mods);

// Both known mods cause one call due to for-loop (2 calls).
// Known-Mod1 causes 1 recursive call (total 3 calls).
Expand Down

0 comments on commit d9b89a7

Please sign in to comment.