diff --git a/jest.config.ts b/jest.config.ts index 88bed42..d80cd92 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -8,4 +8,4 @@ const config: JestConfigWithTsJest = { injectGlobals: true, }; -export default config; \ No newline at end of file +export default config; diff --git a/package.json b/package.json index afa88bc..f7f1b80 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "type": "module", "name": "fomod", "description": "A library for creating, parsing, editing, and validating XML-based Fomod installers, widely popularized in the Bethesda modding scene", - "version": "0.1.9", + "version": "0.1.10", "main": "dist/index.js", "repository": "https://github.com/BellCubeDev/fomod-js/", "bugs": { diff --git a/src/definitions/Dependencies.ts b/src/definitions/Dependencies.ts index 885102c..5235657 100644 --- a/src/definitions/Dependencies.ts +++ b/src/definitions/Dependencies.ts @@ -158,14 +158,13 @@ export class FlagDependency extends Dependency { get desiredValue() { return this.flagInstance.usedValue; } set desiredValue(value: string|boolean) { this.flagInstance.usedValue = value; } - constructor() - constructor(flagName: string, desiredValue: string) + constructor(flagName?: string, desiredValue?: string) constructor(flagName: Option, desiredValue: boolean) constructor(flagName: string|Option = '', desiredValue: string|boolean = '') { super(); // eslint-disable-next-line @typescript-eslint/no-explicit-any - this.flagInstance = new FlagInstance(flagName as any ?? '', desiredValue as any, false); + this.flagInstance = new FlagInstance(flagName as any, desiredValue as any, false); } isValid() { return true; } diff --git a/src/definitions/FlagInstance.ts b/src/definitions/FlagInstance.ts index 3da9da8..a50b99d 100644 --- a/src/definitions/FlagInstance.ts +++ b/src/definitions/FlagInstance.ts @@ -65,7 +65,7 @@ export class FlagInstance extends XmlRepresentation extends XmlRepresentation = new TypeDescriptor(), - public flagsToSet: Set = new Set() + public flagsToSet: Set = new Set(), + public installsToSet: InstallPattern = new InstallPattern(), ) { super(); } @@ -113,7 +114,7 @@ export class Option extends XmlRepresentation(); const conditionFlags = element.getElementsByTagName('conditionFlags')[0]; @@ -143,6 +144,7 @@ export class Option extends XmlRepresentation(name, description, image, typeDescriptor); option.flagsToSet = flagsToSet; + option.installsToSet = installsToSet; const dependencyOnThis = new FlagDependency(option, true); installsToSet.dependencies?.dependencies.add(dependencyOnThis); @@ -448,7 +450,7 @@ export class TypeNameDescriptor { const obj = new Option('apple', 'banana', 'someImage.png'); @@ -19,3 +20,24 @@ describe('Option With Type', () => { test('Type is Correct', () => expect(obj.typeDescriptor.defaultTypeNameDescriptor.targetType).toBe(OptionType.Required)); test('Is Valid', () => expect(obj.isValid()).toBe(true)); }); + +describe('Parsing Option From Element #1', () => { + const doc = parseTag` + + + + + + + `; + + const obj = Option.parse(doc); + + test('We Got An Option', () => expect(obj).toBeInstanceOf(Option)); + test('Name Is Correct', () => expect(obj?.name).toBe('lungs')); + test('Description Is Correct', () => expect(obj?.description).toBe('')); + test('Image Is Correct', () => expect(obj?.image).toBe('12345')); + test('Default Type is Correct', () => expect(obj?.typeDescriptor.defaultTypeNameDescriptor.targetType).toBe(OptionType.CouldBeUsable)); + test('Has No Installs', () => expect(obj?.installsToSet.filesWrapper.installs.size).toBe(0)); + test('Is Valid', () => expect(obj?.isValid()).toBe(true)); +});