import 'mocha' ; import { expect } from 'chai' ; import { FunctionCallArgument } from '@/application/Parser/Script/Compiler/Function/Call/Argument/FunctionCallArgument' ; import { testParameterName } from '../../../ParameterNameTestRunner' ; describe ( 'FunctionCallArgument' , ( ) => { describe ( 'ctor' , ( ) => { describe ( 'parameter name' , ( ) => { testParameterName ( ( parameterName ) => new FunctionCallArgumentBuilder ( ) . withParameterName ( parameterName ) . build ( ) . parameterName ) ; } ) ; it ( 'throws if argument value is undefined' , ( ) => { const parameterName = 'paramName' ; const expectedError = `undefined argument value for "${ parameterName }"` ; const argumentValue = undefined ; const act = ( ) => new FunctionCallArgumentBuilder ( ) . withParameterName ( parameterName ) . withArgumentValue ( argumentValue ) . build ( ) ; expect ( act ) . to . throw ( expectedError ) ; } ) ; } ) ; } ) ; class FunctionCallArgumentBuilder { private parameterName = 'default-parameter-name' ; private argumentValue = 'default-argument-value' ; public withParameterName ( parameterName ) { this . parameterName = parameterName ; return this ; } public withArgumentValue ( argumentValue ) { this . argumentValue = argumentValue ; return this ; } public build ( ) { return new FunctionCallArgument ( this . parameterName , this . argumentValue ) ; } }