Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Commit

Permalink
Removed repeated placeholders
Browse files Browse the repository at this point in the history
- includes integration tests with poe-mods
  • Loading branch information
eps1lon committed Mar 5, 2018
1 parent 483d36c commit 5bd2cb4
Show file tree
Hide file tree
Showing 4 changed files with 312 additions and 48 deletions.
245 changes: 245 additions & 0 deletions src/format/__tests__/__snapshots__/groupMods.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`usage with poe-mods matches the snapshot of 'AddedColdDamagePerDexterity' 1`] = `"Adds # to # Cold Damage to Attacks with this Weapon per 10 Dexterity"`;

exports[`usage with poe-mods matches the snapshot of 'AddedColdDamagePerFrenzyCharge' 1`] = `"# to # Cold Damage per Frenzy Charge"`;

exports[`usage with poe-mods matches the snapshot of 'AddedColdDamageToSpellsAndAttacks' 1`] = `"Adds # to # Cold Damage to Spells and Attacks"`;

exports[`usage with poe-mods matches the snapshot of 'AddedFireDamagePerStrength' 1`] = `"Adds # to # Fire Damage to Attacks with this Weapon per 10 Strength"`;

exports[`usage with poe-mods matches the snapshot of 'AddedFireDamageSpellsAndAttacks' 1`] = `"Adds # to # Fire Damage to Spells and Attacks"`;

exports[`usage with poe-mods matches the snapshot of 'AddedLightningDamagePerIntelligence' 1`] = `"Adds # to # Lightning Damage to Attacks with this Weapon per 10 Intelligence"`;

exports[`usage with poe-mods matches the snapshot of 'AddedLightningDamageSpellsAndAttacks' 1`] = `"Adds # to # Lightning Damage to Spells and Attacks"`;

exports[`usage with poe-mods matches the snapshot of 'AdditionalArrows' 1`] = `"Adds an additional Arrow"`;

exports[`usage with poe-mods matches the snapshot of 'AilmentChanceAddedDamage' 1`] = `"#% chance to * / Adds # to # * Damage against * *"`;

exports[`usage with poe-mods matches the snapshot of 'AllDamage' 1`] = `"#% increased Damage"`;

exports[`usage with poe-mods matches the snapshot of 'AlwaysHits' 1`] = `"Hits can't be Evaded"`;

exports[`usage with poe-mods matches the snapshot of 'AreaDamage' 1`] = `"#% increased Area Damage / Socketed Gems are Supported by Level # Concentrated Effect"`;

exports[`usage with poe-mods matches the snapshot of 'AreaOfEffect' 1`] = `"#% increased Area of Effect *"`;

exports[`usage with poe-mods matches the snapshot of 'AttackDamage' 1`] = `"#% increased Attack Damage"`;

exports[`usage with poe-mods matches the snapshot of 'AttackerTakesDamageNoRange' 1`] = `"Reflects # Physical Damage to Melee Attackers"`;

exports[`usage with poe-mods matches the snapshot of 'BaseLocalDefences' 1`] = `"+# to *"`;

exports[`usage with poe-mods matches the snapshot of 'BaseLocalDefencesAndLife' 1`] = `"+# to *"`;

exports[`usage with poe-mods matches the snapshot of 'BeltFlaskRecoveryRate' 1`] = `"#% increased Flask * Recovery rate"`;

exports[`usage with poe-mods matches the snapshot of 'CannotBeFrozen' 1`] = `"Cannot be Frozen"`;

exports[`usage with poe-mods matches the snapshot of 'CausesBleeding' 1`] = `"* chance to cause Bleeding on Hit"`;

exports[`usage with poe-mods matches the snapshot of 'ColdDamage' 1`] = `"Adds # to # Cold Damage *"`;

exports[`usage with poe-mods matches the snapshot of 'ColdDamageLifeLeech' 1`] = `"#% of Cold Damage Leeched as Life"`;

exports[`usage with poe-mods matches the snapshot of 'ColdResistancePenetration' 1`] = `"Damage Penetrates #% Cold Resistance"`;

exports[`usage with poe-mods matches the snapshot of 'DamageDuringFlaskEffect' 1`] = `"#% increased Damage during any Flask Effect"`;

exports[`usage with poe-mods matches the snapshot of 'DamagePer15Attributes' 1`] = `"#% increased Damage per 15 *"`;

exports[`usage with poe-mods matches the snapshot of 'DamagePerBlockChance' 1`] = `"#% increased Damage per 1% Block Chance"`;

exports[`usage with poe-mods matches the snapshot of 'DamageRemovedFromManaBeforeLife' 1`] = `"#% of Damage is taken from Mana before Life"`;

exports[`usage with poe-mods matches the snapshot of 'DefencesPercent' 1`] = `"#% increased *"`;

exports[`usage with poe-mods matches the snapshot of 'DefencesPercentAndStunRecovery' 1`] = `"#% increased *"`;

exports[`usage with poe-mods matches the snapshot of 'DisplaySocketedGemGetsFortify' 1`] = `"Socketed Gems are Supported by Level # Fortify"`;

exports[`usage with poe-mods matches the snapshot of 'ElementalDamagePercent' 1`] = `"#% increased Elemental Damage"`;

exports[`usage with poe-mods matches the snapshot of 'ElementalDamagePercentAddedAsChaos' 1`] = `"Gain #% of Elemental Damage as Extra Chaos Damage"`;

exports[`usage with poe-mods matches the snapshot of 'ElementalPenetration' 1`] = `"Damage Penetrates #% Elemental Resistances"`;

exports[`usage with poe-mods matches the snapshot of 'EnduranceChargeOnKillChance' 1`] = `"#% chance to gain an Endurance Charge on Kill"`;

exports[`usage with poe-mods matches the snapshot of 'EnergyShieldPercent' 1`] = `"#% increased maximum Energy Shield"`;

exports[`usage with poe-mods matches the snapshot of 'EvasionRatingPercent' 1`] = `"#% increased Evasion Rating"`;

exports[`usage with poe-mods matches the snapshot of 'ExperienceIncrease' 1`] = `"#% increased Experience gain"`;

exports[`usage with poe-mods matches the snapshot of 'FireDamage' 1`] = `"Adds # to # Fire Damage *"`;

exports[`usage with poe-mods matches the snapshot of 'FireDamageAsPortionOfDamage' 1`] = `"Gain #% of Physical Damage as Extra Fire Damage"`;

exports[`usage with poe-mods matches the snapshot of 'FireDamageLifeLeech' 1`] = `"#% of Fire Damage Leeched as Life"`;

exports[`usage with poe-mods matches the snapshot of 'FireResistancePenetration' 1`] = `"Damage Penetrates #% Fire Resistance"`;

exports[`usage with poe-mods matches the snapshot of 'FishingLineStrength' 1`] = `"#% increased Fishing Line Strength"`;

exports[`usage with poe-mods matches the snapshot of 'FishingLureType' 1`] = `"Rhoa Feather Lure"`;

exports[`usage with poe-mods matches the snapshot of 'FishingPoolConsumption' 1`] = `"#% reduced Fishing Pool Consumption"`;

exports[`usage with poe-mods matches the snapshot of 'FlaskChargesUsed' 1`] = `"#% chance for your Flasks to not consume Charges"`;

exports[`usage with poe-mods matches the snapshot of 'FlaskEffect' 1`] = `"#% increased effect of Flasks on You"`;

exports[`usage with poe-mods matches the snapshot of 'FortifyOnMeleeStun' 1`] = `"#% chance to gain Fortify when you Stun an Enemy with Melee Damage"`;

exports[`usage with poe-mods matches the snapshot of 'FrenzyChargeOnKillChance' 1`] = `"#% chance to gain a Frenzy Charge on Kill"`;

exports[`usage with poe-mods matches the snapshot of 'GainArmourIfBlockedRecently' 1`] = `"+# Armour if you've Blocked Recently"`;

exports[`usage with poe-mods matches the snapshot of 'GrantedSkill' 1`] = `"Grants Level # * Cry Skill"`;

exports[`usage with poe-mods matches the snapshot of 'GroundEffectEffectiveness' 1`] = `"Unaffected by * Ground"`;

exports[`usage with poe-mods matches the snapshot of 'IncreaseFlatManaCost' 1`] = `"+# to Total Mana Cost of Skills"`;

exports[`usage with poe-mods matches the snapshot of 'IncreaseSkillGemLevel' 1`] = `"+# to Level of Socketed Active Skill Gems"`;

exports[`usage with poe-mods matches the snapshot of 'IncreaseSocketedGemLevel' 1`] = `"+# to Level of Socketed Gems"`;

exports[`usage with poe-mods matches the snapshot of 'IncreaseSpecificSocketedGemLevel' 1`] = `"+# to Level of Socketed * Gems"`;

exports[`usage with poe-mods matches the snapshot of 'IncreasedEnergyShield' 1`] = `"+# to maximum Energy Shield"`;

exports[`usage with poe-mods matches the snapshot of 'IncreasedEvasionRating' 1`] = `"+# to Evasion Rating"`;

exports[`usage with poe-mods matches the snapshot of 'IncreasedLife' 1`] = `"+# to maximum Life"`;

exports[`usage with poe-mods matches the snapshot of 'IncreasedMana' 1`] = `"+# to maximum Mana"`;

exports[`usage with poe-mods matches the snapshot of 'IncreasedPhysicalDamageReductionRating' 1`] = `"+# to Armour"`;

exports[`usage with poe-mods matches the snapshot of 'IncreasedPhysicalDamageReductionRatingPercent' 1`] = `"#% increased Armour"`;

exports[`usage with poe-mods matches the snapshot of 'IncreasedWeaponElementalDamagePercent' 1`] = `"#% increased Elemental Damage with Attack Skills"`;

exports[`usage with poe-mods matches the snapshot of 'ItemFoundRarityIncreasePrefix' 1`] = `"#% increased Rarity of Items found"`;

exports[`usage with poe-mods matches the snapshot of 'LifeGainPerTarget' 1`] = `"+# Life gained for each Enemy hit by your Attacks"`;

exports[`usage with poe-mods matches the snapshot of 'LifeGainedOnSpellHit' 1`] = `"+# Life gained for each Enemy hit by your Spells"`;

exports[`usage with poe-mods matches the snapshot of 'LifeLeech' 1`] = `"#% of Physical Attack Damage Leeched as Life"`;

exports[`usage with poe-mods matches the snapshot of 'LifeLeechSpeed' 1`] = `"#% increased Life Leeched per second"`;

exports[`usage with poe-mods matches the snapshot of 'LightningDamage' 1`] = `"Adds # to # Lightning Damage *"`;

exports[`usage with poe-mods matches the snapshot of 'LightningDamageLifeLeech' 1`] = `"#% of Lightning Damage Leeched as Life"`;

exports[`usage with poe-mods matches the snapshot of 'LightningResistancePenetration' 1`] = `"Damage Penetrates #% Lightning Resistance"`;

exports[`usage with poe-mods matches the snapshot of 'LocalChaosDamage' 1`] = `"Adds # to # Chaos Damage"`;

exports[`usage with poe-mods matches the snapshot of 'LocalIncreasedPhysicalDamagePercentAndAccuracyRating' 1`] = `"#% increased Physical Damage / +# to Accuracy Rating"`;

exports[`usage with poe-mods matches the snapshot of 'LocalPhysicalDamagePercent' 1`] = `"#% increased Physical Damage"`;

exports[`usage with poe-mods matches the snapshot of 'ManaGainPerTarget' 1`] = `"+# Mana gained for each Enemy hit by your Attacks"`;

exports[`usage with poe-mods matches the snapshot of 'ManaGainedOnSpellHit' 1`] = `"+# Mana gained for each Enemy Hit by your Spells"`;

exports[`usage with poe-mods matches the snapshot of 'ManaLeech' 1`] = `"#% of Physical Attack Damage Leeched as Mana"`;

exports[`usage with poe-mods matches the snapshot of 'MapInvasionMonsterPacks' 1`] = `"Area is inhabited by an additional Invasion Boss / map_item_drop_quantity_+% (hidden)"`;

exports[`usage with poe-mods matches the snapshot of 'MaximumColdResist' 1`] = `"+#% to maximum Cold Resistance"`;

exports[`usage with poe-mods matches the snapshot of 'MaximumFireResist' 1`] = `"+#% to maximum Fire Resistance"`;

exports[`usage with poe-mods matches the snapshot of 'MaximumLeechRate' 1`] = `"+#% of maximum Life per second to maximum Life Leech rate"`;

exports[`usage with poe-mods matches the snapshot of 'MaximumLifeIncreasePercent' 1`] = `"#% increased maximum Life"`;

exports[`usage with poe-mods matches the snapshot of 'MaximumLightningResistance' 1`] = `"+#% to maximum Lightning Resistance"`;

exports[`usage with poe-mods matches the snapshot of 'MaximumManaIncreasePercent' 1`] = `"#% increased maximum Mana"`;

exports[`usage with poe-mods matches the snapshot of 'MaximumMinionCount' 1`] = `"+# to maximum number of Zombies / +# to maximum number of Skeletons / +# to maximum number of Spectres"`;

exports[`usage with poe-mods matches the snapshot of 'MaximumResistances' 1`] = `"+#% to all maximum Resistances"`;

exports[`usage with poe-mods matches the snapshot of 'MinionDamage' 1`] = `"Minions deal #% increased Damage / Socketed Gems are Supported by Level # Minion Damage"`;

exports[`usage with poe-mods matches the snapshot of 'MinionLife' 1`] = `"Minions have #% increased maximum Life / Socketed Gems are Supported by Level # Minion Life"`;

exports[`usage with poe-mods matches the snapshot of 'MovementVelocity' 1`] = `"#% increased Movement Speed"`;

exports[`usage with poe-mods matches the snapshot of 'NonChaosAddedAsChaos' 1`] = `"Gain #% of Non-Chaos Damage as extra Chaos Damage"`;

exports[`usage with poe-mods matches the snapshot of 'PhysicalAddedAsCold' 1`] = `"Gain #% of Physical Damage as Extra Cold Damage"`;

exports[`usage with poe-mods matches the snapshot of 'PhysicalAddedAsFire' 1`] = `"Gain #% of Physical Damage as Extra Fire Damage"`;

exports[`usage with poe-mods matches the snapshot of 'PhysicalAddedAsLightning' 1`] = `"Gain #% of Physical Damage as Extra Lightning Damage"`;

exports[`usage with poe-mods matches the snapshot of 'PhysicalDamage' 1`] = `"Adds # to # Physical Damage *"`;

exports[`usage with poe-mods matches the snapshot of 'PhysicalDamageLifeLeech' 1`] = `"#% of Physical Damage Leeched as Life"`;

exports[`usage with poe-mods matches the snapshot of 'PhysicalDamagePercent' 1`] = `"#% increased Global Physical Damage"`;

exports[`usage with poe-mods matches the snapshot of 'PhysicalDamageTakenAsCold' 1`] = `"#% of Physical Damage taken as Cold Damage"`;

exports[`usage with poe-mods matches the snapshot of 'PhysicalDamageTakenAsElementUber' 1`] = `"#% of Physical Damage taken as * Damage"`;

exports[`usage with poe-mods matches the snapshot of 'PhysicalDamageTakenAsFirePercent' 1`] = `"#% of Physical Damage taken as Fire Damage"`;

exports[`usage with poe-mods matches the snapshot of 'Pierce' 1`] = `"Projectiles Pierce * additional *"`;

exports[`usage with poe-mods matches the snapshot of 'PoisonDamage' 1`] = `"#% increased Damage with Poison"`;

exports[`usage with poe-mods matches the snapshot of 'PowerChargeOnKillChance' 1`] = `"#% chance to gain a Power Charge on Kill"`;

exports[`usage with poe-mods matches the snapshot of 'ProjectileDamage' 1`] = `"#% increased Projectile Damage / Socketed Gems are Supported by Level # Slower Projectiles"`;

exports[`usage with poe-mods matches the snapshot of 'ProjectileSpeed' 1`] = `"#% increased Projectile Speed / Socketed Gems are supported by Level # Faster Projectiles"`;

exports[`usage with poe-mods matches the snapshot of 'RarityDuringFlaskEffect' 1`] = `"#% increased Rarity of Items found during any Flask Effect"`;

exports[`usage with poe-mods matches the snapshot of 'ReducedCriticalStrikeDamageTaken' 1`] = `"You take #% reduced Extra Damage from Critical Strikes"`;

exports[`usage with poe-mods matches the snapshot of 'ReflectedDamage' 1`] = `"#% reduced Reflected * Damage taken"`;

exports[`usage with poe-mods matches the snapshot of 'SpellAddedChaosDamage' 1`] = `"Adds # to # Chaos Damage to Spells"`;

exports[`usage with poe-mods matches the snapshot of 'SpellAddedColdDamageUber' 1`] = `"Adds # to # Cold Damage to Spells"`;

exports[`usage with poe-mods matches the snapshot of 'SpellAddedElementalDamage' 1`] = `"Adds # to # * Damage to Spells"`;

exports[`usage with poe-mods matches the snapshot of 'SpellAddedFireDamageUber' 1`] = `"Adds # to # Fire Damage to Spells"`;

exports[`usage with poe-mods matches the snapshot of 'SpellAddedLightningDamageUber' 1`] = `"Adds # to # Lightning Damage to Spells"`;

exports[`usage with poe-mods matches the snapshot of 'SpellAddedPhysicalDamage' 1`] = `"Adds # to # Physical Damage to Spells"`;

exports[`usage with poe-mods matches the snapshot of 'SpellDamage' 1`] = `"#% increased Spell Damage"`;

exports[`usage with poe-mods matches the snapshot of 'SpellDamageAndMana' 1`] = `"#% increased Spell Damage / +# to maximum Mana"`;

exports[`usage with poe-mods matches the snapshot of 'SpellDamagePerDexterity' 1`] = `"#% increased Spell Damage per 16 Dexterity"`;

exports[`usage with poe-mods matches the snapshot of 'SpellDamagePerIntelligence' 1`] = `"#% increased Spell Damage per * Intelligence"`;

exports[`usage with poe-mods matches the snapshot of 'SpellDamagePerStrength' 1`] = `"#% increased Spell Damage per * Strength"`;

exports[`usage with poe-mods matches the snapshot of 'SupportGemQuality' 1`] = `"+#% to Quality of Socketed Support Gems"`;

exports[`usage with poe-mods matches the snapshot of 'Supported' 1`] = `"Socketed Gems are Supported by Level # *"`;

exports[`usage with poe-mods matches the snapshot of 'SupportedByLifeLeech' 1`] = `"Socketed Gems are supported by Level # Life Leech"`;

exports[`usage with poe-mods matches the snapshot of 'SupportedByTrigger' 1`] = `"Socketed Gems are * by Level # Cast * * *"`;

exports[`usage with poe-mods matches the snapshot of 'WeaponCasterDamagePrefix' 1`] = `"#% increased * Damage"`;
83 changes: 46 additions & 37 deletions src/format/__tests__/groupMods.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { createMods, Mod } from 'poe-mods';

import groupMods, { Stat, Options } from '../groupMods';
import { Fallback } from '../stats';
import datas from '../../__fixtures__/english';
import { create } from 'domain';
import groupMods, { Options, Stat } from '../groupMods';
import { Fallback } from '../stats';

it('merges multiple mods (mod = one ore more stats) into a single line', () => {
expect(
Expand Down Expand Up @@ -57,42 +56,52 @@ it('its resolve conflict strategy can be configured', () => {
).toEqual('+# to Level of Socketed * Gems');
});

it.only(
'is designed to create a description of correct_group in eps1lon/poe-mods',
() => {
const groupByCorrectGroup = (mods: Mod['props'][]) => {
return mods.reduce((groups, mod) => {
if (!groups.has(mod.correct_group)) {
groups.set(mod.correct_group, []);
}
groups.get(mod.correct_group)!.push(
mod.stats.map((stat, i) => {
const key_min = `stat${i + 1}_min` as keyof typeof mod;
const key_max = `stat${i + 1}_min` as keyof typeof mod;
describe.only('usage with poe-mods', () => {
const modStats = (mod: Mod['props']) =>
mod.stats.map((stat, i) => {
const key_min = `stat${i + 1}_min` as keyof typeof mod;
const key_max = `stat${i + 1}_min` as keyof typeof mod;

return {
id: stat.id,
value: [+mod[key_min], +mod[key_max]] as [number, number]
};
})
);
return groups;
}, new Map<string, Stat[][]>());
};
return {
id: stat.id,
value: [+mod[key_min], +mod[key_max]] as [number, number]
};
});
const groupByCorrectGroup = (mods: Array<Mod['props']>) => {
return mods.reduce((groups, mod) => {
if (!groups.has(mod.correct_group)) {
groups.set(mod.correct_group, []);
}
groups.get(mod.correct_group)!.push(modStats(mod));
return groups;
}, new Map<string, Stat[][]>());
};

const locale_data = {
stat_descriptions: require('../../../locale-data/en/stat_descriptions.json')
};
const locale_data = {
stat_descriptions: require('../../../locale-data/en/stat_descriptions.json')
};

const options: Partial<Options> = {
datas: locale_data,
fallback: Fallback.skip
};
const options: Partial<Options> = {
datas: locale_data,
fallback: Fallback.skip
};

const prefixes = createMods(require('poe-mods/data/mods/prefixes.json'));
const prefix_groups = groupByCorrectGroup(prefixes.all());
for (const [correct_group, mods] of prefix_groups.entries()) {
console.log(correct_group, groupMods(mods, options));
}
const prefixes = createMods(require('poe-mods/data/mods/prefixes.json'));
// skip monster domain
const prefix_groups = groupByCorrectGroup(
prefixes.all().filter(mod => mod.domain === 1)
);
for (const [correct_group, mods] of prefix_groups.entries()) {
it(`matches the snapshot of '${correct_group}'`, () => {
expect(groupMods(mods, options)).toMatchSnapshot();
});
}
);

it('groups matching words', () => {
const group = prefixes
.all()
.filter(mod => mod.correct_group === 'AreaOfEffect');
const t = groupMods(group.map(modStats), options);
expect(t).toEqual('#% increased Area of Effect *');
});
});
Loading

0 comments on commit 5bd2cb4

Please sign in to comment.