import { given , when , then , Assert } from '../node_modules/typespec-bdd/src/TypeSpec' ; import { Calculator } from '../Scripts/Calculator' ; export interface CalculatorTestContext { done : Function ; calculator : Calculator ; } export class CalculatorSteps { @ given ( /I am using a calculator/i ) usingCalculator ( context ) { context . calculator = new Calculator ( ) ; } @ given ( /I enter (\"\d+\") into the calculator/i ) enterNumber ( context , num ) { context . calculator . add ( num ) ; } @ given ( /I enter (\"\d+\") and (\"\d+\") into the calculator/i ) enterNumbers ( context , num1 , num2 ) { context . calculator . add ( num1 ) ; context . calculator . add ( num2 ) ; } @ when ( /I press the total button/gi ) pressTotal ( context ) { } @ then ( /the result should be (\"\d+\") on the screen/i ) resultShouldBe ( context , expected ) { const actual = context . calculator . getTotal ( ) ; Assert . areIdentical ( expected , actual ) ; } }