Closed
Description
The tests follow the old spec format where the code executed is part of the test name. The tests should be changed to:
- Get rid of the matrix tests. Instead, write out each test to be descriptive. This aids the test runner.
- Get rid of the constructed names in the tests. Instead make the test names descriptive.
THE CHANGE BELOW has already been made, but we'd like the same for all the other tests.
⚠ When possible, don't be overly verbose. Concretely:DO NOT: "when the knight, the archer and the prisoner are asleep"
DO: "when everyone is asleep".DO NOT: "when the knight is awake, the archer is asleep, and the prisoner is asleep"
DO: "when only the knight is awake".
Current
describe('canExecuteFastAttack', () => {
let knightIsAwake = true;
let expected = false;
test(`canExecuteFastAttack(${knightIsAwake})`, () => {
expect(canExecuteFastAttack(knightIsAwake)).toBe(expected);
});
knightIsAwake = false;
expected = true;
test(`canExecuteFastAttack(${knightIsAwake})`, () => {
expect(canExecuteFastAttack(knightIsAwake)).toBe(expected);
});
});
Expected
describe('can execute fast attack', () => {
test(`when the knight is awake`, () => {
const knightIsAwake = true;
const expected = false;
expect(canExecuteFastAttack(knightIsAwake)).toBe(expected);
});
test(`when the knight is asleep`, () => {
const knightIsAwake = false;
const expected = true;
expect(canExecuteFastAttack(knightIsAwake)).toBe(expected);
});
});
Additional information
The primary reason this change is wanted is of how the test runner works.
let knightIsAwake = true;
let expected = false;
test(`canExecuteFastAttack(${knightIsAwake})`, () => {
expect(canExecuteFastAttack(knightIsAwake)).toBe(expected);
});
This will show up for the student as:
Test: canExecuteFastAttack > canExecuteFastAttack(true)
Code ran:
expect(canExecuteFastAttack(knightIsAwake)).toBe(expected)
Instead, the proposed better alternative shows up as:
Test: can execute fast attack > when the knight is awake
Code ran:
const knightIsAwake = true; const expected = false; expect(canExecuteFastAttack(knightIsAwake)).toBe(expected);