-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from pplancq/feature/eslint
- Loading branch information
Showing
67 changed files
with
8,452 additions
and
4,120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npx lint-staged |
57 changes: 29 additions & 28 deletions
57
examples/ecmascript/specs/step-definitions/auto-step-binding.steps.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
import { loadFeatures, autoBindSteps } from 'jest-cucumber'; | ||
import { VendingMachine } from '../../src/vending-machine'; | ||
|
||
export const vendingMachineSteps = ({ given, and, when, then }) => { | ||
let vendingMachine; | ||
|
||
given(/^the vending machine has "(.*)" in stock$/, (itemName) => { | ||
vendingMachine = new VendingMachine(); | ||
vendingMachine.stockItem(itemName, 1); | ||
}); | ||
|
||
and('I have inserted the correct amount of money', () => { | ||
vendingMachine.insertMoney(0.50); | ||
}); | ||
|
||
when(/^I purchase "(.*)"$/, (itemName) => { | ||
vendingMachine.dispenseItem(itemName); | ||
}); | ||
|
||
then(/^my "(.*)" should be dispensed$/, (itemName) => { | ||
const inventoryAmount = vendingMachine.items[itemName]; | ||
expect(inventoryAmount).toBe(0); | ||
}); | ||
}; | ||
|
||
const features = loadFeatures('./specs/features/auto-binding/**/*.feature'); | ||
|
||
autoBindSteps(features, [ vendingMachineSteps ]); | ||
// eslint-disable-next-line import/no-unresolved | ||
import { loadFeatures, autoBindSteps } from 'jest-cucumber'; | ||
import { VendingMachine } from '../../src/vending-machine'; | ||
|
||
export const vendingMachineSteps = ({ given, and, when, then }) => { | ||
let vendingMachine; | ||
|
||
given(/^the vending machine has "(.*)" in stock$/, itemName => { | ||
vendingMachine = new VendingMachine(); | ||
vendingMachine.stockItem(itemName, 1); | ||
}); | ||
|
||
and('I have inserted the correct amount of money', () => { | ||
vendingMachine.insertMoney(0.5); | ||
}); | ||
|
||
when(/^I purchase "(.*)"$/, itemName => { | ||
vendingMachine.dispenseItem(itemName); | ||
}); | ||
|
||
then(/^my "(.*)" should be dispensed$/, itemName => { | ||
const inventoryAmount = vendingMachine.items[itemName]; | ||
expect(inventoryAmount).toBe(0); | ||
}); | ||
}; | ||
|
||
const features = loadFeatures('./specs/features/auto-binding/**/*.feature'); | ||
|
||
autoBindSteps(features, [vendingMachineSteps]); |
145 changes: 73 additions & 72 deletions
145
examples/ecmascript/specs/step-definitions/backgrounds.steps.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,73 @@ | ||
import { loadFeature, defineFeature } from 'jest-cucumber'; | ||
import { ArcadeMachine, COIN_TYPES } from '../../src/arcade-machine'; | ||
|
||
const feature = loadFeature('./specs/features/backgrounds.feature'); | ||
|
||
defineFeature(feature, (test) => { | ||
let arcadeMachine; | ||
|
||
beforeEach(() => { | ||
arcadeMachine = new ArcadeMachine(); | ||
}); | ||
|
||
const givenMyMachineIsConfiguredToRequireCoins = (given) => { | ||
given('my machine is configured to require coins', () => { | ||
arcadeMachine.requireCoins = true; | ||
}); | ||
}; | ||
|
||
const givenMyMachineIsConfiguredToAcceptUsQuarters = (given) => { | ||
given('my machine is configured to accept US Quarters', () => { | ||
arcadeMachine.acceptedCoinType = COIN_TYPES.USQuarter; | ||
}); | ||
}; | ||
|
||
test('Successfully inserting coins', ({ given, when, then }) => { | ||
givenMyMachineIsConfiguredToRequireCoins(given); | ||
|
||
given('I have not inserted any coins', () => { | ||
arcadeMachine.balance = 0; | ||
}); | ||
|
||
when('I insert one US quarter', () => { | ||
arcadeMachine.insertCoin(COIN_TYPES.USQuarter); | ||
}); | ||
|
||
then(/^I should have a balance of (\d+) cents$/, (balance) => { | ||
arcadeMachine.balance = balance / 100; | ||
}); | ||
}); | ||
|
||
test('Inserting a Canadian coin', ({ given, when, then }) => { | ||
let coinStatus; | ||
|
||
givenMyMachineIsConfiguredToRequireCoins(given); | ||
|
||
givenMyMachineIsConfiguredToAcceptUsQuarters(given); | ||
|
||
when('I insert a Canadian Quarter', () => { | ||
coinStatus = arcadeMachine.insertCoin(COIN_TYPES.CanadianQuarter); | ||
}); | ||
|
||
then('my coin should be returned', () => { | ||
expect(coinStatus).toBe('CoinReturned'); | ||
}); | ||
}); | ||
|
||
test('Inserting a badly damaged coin', ({ given, when, then }) => { | ||
let coinStatus; | ||
|
||
givenMyMachineIsConfiguredToRequireCoins(given); | ||
|
||
givenMyMachineIsConfiguredToAcceptUsQuarters(given); | ||
|
||
when('I insert a US Quarter that is badly damaged', () => { | ||
coinStatus = arcadeMachine.insertCoin(COIN_TYPES.Unknown); | ||
}); | ||
|
||
then('my coin should be returned', () => { | ||
expect(coinStatus).toBe('CoinReturned'); | ||
}); | ||
}); | ||
}); | ||
// eslint-disable-next-line import/no-unresolved | ||
import { loadFeature, defineFeature } from 'jest-cucumber'; | ||
import { ArcadeMachine, COIN_TYPES } from '../../src/arcade-machine'; | ||
|
||
const feature = loadFeature('./specs/features/backgrounds.feature'); | ||
|
||
defineFeature(feature, test => { | ||
let arcadeMachine; | ||
|
||
beforeEach(() => { | ||
arcadeMachine = new ArcadeMachine(); | ||
}); | ||
|
||
const givenMyMachineIsConfiguredToRequireCoins = given => { | ||
given('my machine is configured to require coins', () => { | ||
arcadeMachine.requireCoins = true; | ||
}); | ||
}; | ||
|
||
const givenMyMachineIsConfiguredToAcceptUsQuarters = given => { | ||
given('my machine is configured to accept US Quarters', () => { | ||
arcadeMachine.acceptedCoinType = COIN_TYPES.USQuarter; | ||
}); | ||
}; | ||
|
||
test('Successfully inserting coins', ({ given, when, then }) => { | ||
givenMyMachineIsConfiguredToRequireCoins(given); | ||
|
||
given('I have not inserted any coins', () => { | ||
arcadeMachine.balance = 0; | ||
}); | ||
|
||
when('I insert one US quarter', () => { | ||
arcadeMachine.insertCoin(COIN_TYPES.USQuarter); | ||
}); | ||
|
||
then(/^I should have a balance of (\d+) cents$/, balance => { | ||
arcadeMachine.balance = balance / 100; | ||
}); | ||
}); | ||
|
||
test('Inserting a Canadian coin', ({ given, when, then }) => { | ||
let coinStatus; | ||
|
||
givenMyMachineIsConfiguredToRequireCoins(given); | ||
|
||
givenMyMachineIsConfiguredToAcceptUsQuarters(given); | ||
|
||
when('I insert a Canadian Quarter', () => { | ||
coinStatus = arcadeMachine.insertCoin(COIN_TYPES.CanadianQuarter); | ||
}); | ||
|
||
then('my coin should be returned', () => { | ||
expect(coinStatus).toBe('CoinReturned'); | ||
}); | ||
}); | ||
|
||
test('Inserting a badly damaged coin', ({ given, when, then }) => { | ||
let coinStatus; | ||
|
||
givenMyMachineIsConfiguredToRequireCoins(given); | ||
|
||
givenMyMachineIsConfiguredToAcceptUsQuarters(given); | ||
|
||
when('I insert a US Quarter that is badly damaged', () => { | ||
coinStatus = arcadeMachine.insertCoin(COIN_TYPES.Unknown); | ||
}); | ||
|
||
then('my coin should be returned', () => { | ||
expect(coinStatus).toBe('CoinReturned'); | ||
}); | ||
}); | ||
}); |
33 changes: 17 additions & 16 deletions
33
examples/ecmascript/specs/step-definitions/basic-scenarios.steps.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,28 @@ | ||
// eslint-disable-next-line import/no-unresolved | ||
import { defineFeature, loadFeature } from 'jest-cucumber'; | ||
import { PasswordValidator } from '../../src/password-validator'; | ||
|
||
const feature = loadFeature('./specs/features/basic-scenarios.feature'); | ||
|
||
defineFeature(feature, (test) => { | ||
let passwordValidator = new PasswordValidator(); | ||
let accessGranted = false; | ||
defineFeature(feature, test => { | ||
let passwordValidator = new PasswordValidator(); | ||
let accessGranted = false; | ||
|
||
beforeEach(() => { | ||
passwordValidator = new PasswordValidator(); | ||
}); | ||
beforeEach(() => { | ||
passwordValidator = new PasswordValidator(); | ||
}); | ||
|
||
test('Entering a correct password', ({ given, when, then }) => { | ||
given('I have previously created a password', () => { | ||
passwordValidator.setPassword('1234'); | ||
}); | ||
test('Entering a correct password', ({ given, when, then }) => { | ||
given('I have previously created a password', () => { | ||
passwordValidator.setPassword('1234'); | ||
}); | ||
|
||
when('I enter my password correctly', () => { | ||
accessGranted = passwordValidator.validatePassword('1234'); | ||
}); | ||
when('I enter my password correctly', () => { | ||
accessGranted = passwordValidator.validatePassword('1234'); | ||
}); | ||
|
||
then('I should be granted access', () => { | ||
expect(accessGranted).toBe(true); | ||
}); | ||
then('I should be granted access', () => { | ||
expect(accessGranted).toBeTrue(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 19 additions & 18 deletions
37
examples/ecmascript/specs/step-definitions/scenario-outlines.steps.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,28 @@ | ||
// eslint-disable-next-line import/no-unresolved | ||
import { defineFeature, loadFeature } from 'jest-cucumber'; | ||
import { OnlineSales } from '../../src/online-sales'; | ||
|
||
const feature = loadFeature('./specs/features/scenario-outlines.feature'); | ||
|
||
defineFeature(feature, test => { | ||
let onlineSales; | ||
let salesPrice; | ||
|
||
beforeEach(() => { | ||
onlineSales = new OnlineSales(); | ||
}); | ||
let onlineSales; | ||
let salesPrice; | ||
|
||
test('Selling an <Item> at $<Amount>', ({ given, when, then, pending }) => { | ||
given(/^I have a\(n\) (.*)$/, item => { | ||
onlineSales.listItem(item); | ||
}); | ||
beforeEach(() => { | ||
onlineSales = new OnlineSales(); | ||
}); | ||
|
||
when(/^I sell the (.*)$/, item => { | ||
salesPrice = onlineSales.sellItem(item); | ||
}); | ||
test('Selling an <Item> at $<Amount>', ({ given, when, then }) => { | ||
given(/^I have a\(n\) (.*)$/, item => { | ||
onlineSales.listItem(item); | ||
}); | ||
|
||
then(/^I should get \$(\d+)$/, expectedSalesPrice => { | ||
expect(salesPrice).toBe(parseInt(expectedSalesPrice)); | ||
}); | ||
}); | ||
}); | ||
when(/^I sell the (.*)$/, item => { | ||
salesPrice = onlineSales.sellItem(item); | ||
}); | ||
|
||
then(/^I should get \$(\d+)$/, expectedSalesPrice => { | ||
expect(salesPrice).toBe(parseInt(expectedSalesPrice, 10)); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.