forked from bencompton/jest-cucumber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto-step-binding.steps.ts
28 lines (21 loc) · 1.01 KB
/
auto-step-binding.steps.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { StepDefinitions, loadFeatures, autoBindSteps } from '../../../../src';
import { VendingMachine } from '../../src/vending-machine';
export const vendingMachineSteps: StepDefinitions = ({ given, and, when, then }) => {
let vendingMachine: VendingMachine;
given(/^the vending machine has "(.*)" in stock$/, (itemName: string) => {
vendingMachine = new VendingMachine();
vendingMachine.stockItem(itemName, 1);
});
and('I have inserted the correct amount of money', () => {
vendingMachine.insertMoney(0.50);
});
when(/^I purchase "(.*)"$/, (itemName: string) => {
vendingMachine.dispenseItem(itemName);
});
then(/^my "(.*)" should be dispensed$/, (itemName: string) => {
const inventoryAmount = vendingMachine.items[itemName];
expect(inventoryAmount).toBe(0);
});
};
const features = loadFeatures('./examples/typescript/specs/features/auto-binding/**/*.feature');
autoBindSteps(features, [ vendingMachineSteps ]);