Skip to content

Commit

Permalink
acceptance test for replenishing
Browse files Browse the repository at this point in the history
  • Loading branch information
customcommander committed Oct 12, 2024
1 parent 36a79f2 commit d9ca0bf
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 9 deletions.
41 changes: 41 additions & 0 deletions test/acceptance/replenish.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Feature: Replenish

Scenario: Game automatically replenishes stock
Given I start playing
Then I have the following stock on the board
| Stock | Quantity |
| Wood | 2 |
| Clay | 1 |
| Reed | 1 |
| Food | 1 |

# Turn 1
When I select "Take 1 Grain"
And I select "Day Laborer"
Then I have the following stock on the board
| Stock | Quantity |
| Wood | 4 |
| Clay | 2 |
| Reed | 2 |
| Food | 2 |

# Turn 2
When I select "Take 1 Grain"
And I select "Day Laborer"
Then I have the following stock on the board
| Stock | Quantity |
| Wood | 6 |
| Clay | 3 |
| Reed | 3 |
| Food | 3 |

# Turn 3
When I select "Take 1 Grain"
And I select "Day Laborer"
Then I have the following stock on the board
| Stock | Quantity |
| Wood | 8 |
| Clay | 4 |
| Reed | 4 |
| Food | 4 |

34 changes: 25 additions & 9 deletions test/acceptance/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,28 @@ import {
Then
} from '@cucumber/cucumber';

const task_map = {
'Day Laborer' : 106,
'Plow 1 Field' : 104,
'Sow and/or Bake bread': 113,
'Take 1 Grain' : 103,
'Take x Clay' : 108,
'Take x Reed' : 109,
'Take x Wood' : 107,
};

const stock_map = {
'Clay': 108,
'Food': 110,
'Reed': 109,
'Wood': 107,
}

Given('I start playing', async function () {
await this.start();
});

When('I select {string}', async function (selection) {
const task_map = {
'Take 1 Grain' : 103,
'Plow 1 Field' : 104,
'Take x Wood' : 107,
'Take x Clay' : 108,
'Take x Reed' : 109,
'Sow and/or Bake bread': 113
};

await this.send({type: 'task.selected', task_id: task_map[selection]});
});

Expand All @@ -44,3 +52,11 @@ Then('the current turn is {int}', async function (expected_turn) {
await this.assert(({turn}) => turn === expected_turn);
});

Then('I have the following stock on the board', async function (table) {
await this.assert(game => table.hashes().every(({Stock, Quantity}) => {
const task_id = stock_map[Stock];
const {quantity} = game.tasks[task_id];
return quantity === Number(Quantity);
}));
});

0 comments on commit d9ca0bf

Please sign in to comment.