Skip to content

Commit

Permalink
🐞 Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vforvasile committed Apr 4, 2023
1 parent 01f7546 commit 5a833f5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/components/creature/CreatureStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ export default function CreatureStats({
const savingThrows = creature.proficiencies ? creature.proficiencies.filter((ability) => ability.proficiency?.index.includes('saving-throw')) : [];
const skills = creature.proficiencies ? creature.proficiencies.filter((ability) => ability.proficiency?.index.includes('skill')) : [];

console.log(`creature ${creature.name}`, creature);

const toggleCreatureStats = () => {
setCreatureStats((prevValue) => !prevValue);
};
Expand Down
4 changes: 1 addition & 3 deletions src/components/creature/CreatureWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CreatureWrapper extends Component {
super(props);

this.state = {
expanded: true,
expanded: false,
showSpellCreator: false,
};

Expand Down Expand Up @@ -185,8 +185,6 @@ class CreatureWrapper extends Component {
rightPercentage,
] = getHitPointsBar(creatureHealthPoints, maxHealthPoints, alive, showHitPoints);

console.log('current creature state', creature, showSpellCreator);

return (
<>
<section
Expand Down
4 changes: 2 additions & 2 deletions src/state/CreatureListManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ describe('addCreature', () => {
ariaAnnouncements: ['creatures added'],
};

const newState = addCreature(defaultState, creature);
const newState = addCreature(defaultState, { ...creature, syncMultipleInitiatives: true });

expect(newState).toEqual(expectedState);
expect(createCreature.mock.calls.length).toBe(2);
Expand Down Expand Up @@ -437,7 +437,7 @@ describe('addCreature', () => {
ariaAnnouncements: ['creatures added'],
};

const newState = addCreature(initialState, creature);
const newState = addCreature(initialState, { ...creature, syncMultipleInitiatives: true });

expect(newState).toEqual(expectedState);
expect(createCreature.mock.calls.length).toBe(2);
Expand Down
16 changes: 12 additions & 4 deletions src/state/CreatureManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ export function createCreature(creatureId, {
armorClass, name, number, initiative, healthPoints, apiData, spellData,
}) {
const groupedName = number ? `${name} #${number}` : name;
return {
armorClass,
const finalCreature = {
name: groupedName,
initiative,
healthPoints,
Expand All @@ -256,9 +255,18 @@ export function createCreature(creatureId, {
locked: false,
shared: true,
hitPointsShared: true,
apiData,
spellData,
};

if (armorClass) {
finalCreature.armorClass = armorClass;
}
if (apiData) {
finalCreature.apiData = apiData;
}
if (spellData) {
finalCreature.spellData = spellData;
}
return finalCreature;
}

export function validateCreature(name, initiative, healthPoints, multiplier) {
Expand Down
1 change: 0 additions & 1 deletion test-integration/page-object-models/dmApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export default class DmApp extends DndBattleTracker {

async addCreature(name, initiative, hp, multiply) {
await this.enterCreatureName(name);

if (initiative) {
const initiativeField = await screen.findByText('Initiative (optional)');
await this.user.type(initiativeField, initiative);
Expand Down

0 comments on commit 5a833f5

Please sign in to comment.