Tested folders, notes, and rolls
This commit is contained in:
@@ -125,7 +125,6 @@ describe('Interrupt action system', function () {
|
|||||||
name: 'New Roll',
|
name: 'New Roll',
|
||||||
value: '7d1 [1, 1, 1, 1, 1, 1, 1] + 9\n**16**',
|
value: '7d1 [1, 1, 1, 1, 1, 1, 1] + 9\n**16**',
|
||||||
inline: true,
|
inline: true,
|
||||||
silenced: undefined,
|
|
||||||
}, {
|
}, {
|
||||||
value: 'rollVar: 16'
|
value: 'rollVar: 16'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import { assert } from 'chai';
|
||||||
|
import {
|
||||||
|
allMutations,
|
||||||
|
createTestCreature,
|
||||||
|
getRandomIds,
|
||||||
|
removeAllCreaturesAndProps,
|
||||||
|
runActionById
|
||||||
|
} from '/imports/api/engine/action/functions/actionEngineTest.testFn';
|
||||||
|
|
||||||
|
const [
|
||||||
|
creatureId, folderId
|
||||||
|
] = getRandomIds(100);
|
||||||
|
|
||||||
|
const actionTestCreature = {
|
||||||
|
_id: creatureId,
|
||||||
|
props: [
|
||||||
|
{
|
||||||
|
_id: folderId,
|
||||||
|
type: 'folder',
|
||||||
|
children: [{
|
||||||
|
type: 'note',
|
||||||
|
summary: { text: 'this should run' },
|
||||||
|
}],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('Apply folder properties', function () {
|
||||||
|
// Increase timeout
|
||||||
|
this.timeout(8000);
|
||||||
|
|
||||||
|
before(async function () {
|
||||||
|
await removeAllCreaturesAndProps();
|
||||||
|
await createTestCreature(actionTestCreature);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Applies the children of the folder', async function () {
|
||||||
|
const action = await runActionById(folderId);
|
||||||
|
assert.exists(action);
|
||||||
|
assert.deepEqual(allMutations(action), [{
|
||||||
|
contents: [
|
||||||
|
{
|
||||||
|
value: 'this should run'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
targetIds: [],
|
||||||
|
}]);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { assert } from 'chai';
|
||||||
|
import {
|
||||||
|
allMutations,
|
||||||
|
createTestCreature,
|
||||||
|
getRandomIds,
|
||||||
|
removeAllCreaturesAndProps,
|
||||||
|
runActionById
|
||||||
|
} from '/imports/api/engine/action/functions/actionEngineTest.testFn';
|
||||||
|
|
||||||
|
const [
|
||||||
|
creatureId, noteId
|
||||||
|
] = getRandomIds(2);
|
||||||
|
|
||||||
|
const actionTestCreature = {
|
||||||
|
_id: creatureId,
|
||||||
|
props: [
|
||||||
|
{
|
||||||
|
_id: noteId,
|
||||||
|
type: 'note',
|
||||||
|
name: 'Note Name',
|
||||||
|
summary: { text: 'Note summary {1 + 2}' }
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('Apply note properties', function () {
|
||||||
|
// Increase timeout
|
||||||
|
this.timeout(8000);
|
||||||
|
|
||||||
|
before(async function () {
|
||||||
|
await removeAllCreaturesAndProps();
|
||||||
|
await createTestCreature(actionTestCreature);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Applies the note text', async function () {
|
||||||
|
const action = await runActionById(noteId);
|
||||||
|
assert.exists(action);
|
||||||
|
assert.deepEqual(allMutations(action), [{
|
||||||
|
contents: [
|
||||||
|
{
|
||||||
|
name: 'Note Name',
|
||||||
|
value: 'Note summary 3'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
targetIds: [],
|
||||||
|
}]);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { assert } from 'chai';
|
||||||
|
import {
|
||||||
|
allLogContent,
|
||||||
|
createTestCreature,
|
||||||
|
getRandomIds,
|
||||||
|
removeAllCreaturesAndProps,
|
||||||
|
runActionById
|
||||||
|
} from '/imports/api/engine/action/functions/actionEngineTest.testFn';
|
||||||
|
|
||||||
|
const [
|
||||||
|
creatureId, rollId,
|
||||||
|
] = getRandomIds(2);
|
||||||
|
|
||||||
|
const actionTestCreature = {
|
||||||
|
_id: creatureId,
|
||||||
|
props: [
|
||||||
|
{
|
||||||
|
_id: rollId,
|
||||||
|
type: 'roll',
|
||||||
|
name: 'Roll Name',
|
||||||
|
variableName: 'roll1',
|
||||||
|
roll: { calculation: '7 + 15' },
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
type: 'note',
|
||||||
|
summary: { text: 'roll: {roll1}' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('Apply roll properties', function () {
|
||||||
|
// Increase timeout
|
||||||
|
this.timeout(8000);
|
||||||
|
|
||||||
|
before(async function () {
|
||||||
|
await removeAllCreaturesAndProps();
|
||||||
|
await createTestCreature(actionTestCreature);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Saves the value of the roll into the variable name', async function () {
|
||||||
|
const action = await runActionById(rollId);
|
||||||
|
assert.exists(action);
|
||||||
|
assert.deepEqual(allLogContent(action), [{
|
||||||
|
inline: true,
|
||||||
|
name: 'Roll Name',
|
||||||
|
value: '**22**',
|
||||||
|
}, {
|
||||||
|
value: 'roll: 22',
|
||||||
|
}]);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -52,7 +52,7 @@ export default async function applyRollProperty(
|
|||||||
name: prop.name,
|
name: prop.name,
|
||||||
value: logValue.join('\n'),
|
value: logValue.join('\n'),
|
||||||
inline: true,
|
inline: true,
|
||||||
silenced: prop.silent,
|
...prop.silent && { silenced: true },
|
||||||
}, task.targetIds);
|
}, task.targetIds);
|
||||||
|
|
||||||
// Apply children
|
// Apply children
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ const inputProviderForTests: InputProvider = {
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* For testing, randomness is hard to deal with
|
* For testing, randomness is hard to deal with
|
||||||
* rollDice function returns the average roll for every dice rolled
|
* rollDice function returns the average roll for every dice rolled, but increasing by one each time
|
||||||
* [5d10, 1d4] => [[6,6,6,6,6], [3]]
|
* [6d10, 1d4] => [[6,7,8,9,10,1], [3]]
|
||||||
*/
|
*/
|
||||||
async rollDice(dice = []) {
|
async rollDice(dice = []) {
|
||||||
const result: number[][] = [];
|
const result: number[][] = [];
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ let ComputedOnlyBranchSchema = createPropertySchema({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const ComputedBranchSchema = new SimpleSchema()
|
const ComputedBranchSchema = new SimpleSchema({})
|
||||||
.extend(BranchSchema)
|
.extend(BranchSchema)
|
||||||
.extend(ComputedOnlyBranchSchema);
|
.extend(ComputedOnlyBranchSchema);
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ let ComputedOnlyRollSchema = createPropertySchema({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const ComputedRollSchema = new SimpleSchema()
|
const ComputedRollSchema = new SimpleSchema({})
|
||||||
.extend(RollSchema)
|
.extend(RollSchema)
|
||||||
.extend(ComputedOnlyRollSchema);
|
.extend(ComputedOnlyRollSchema);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user