import 'mocha' ; import { expect } from 'chai' ; import { CodePosition } from '@/application/Context/State/Code/Position/CodePosition' ; describe ( 'CodePosition' , ( ) => { describe ( 'ctor' , ( ) => { it ( 'creates with valid parameters' , ( ) => { const startPosition = 0 ; const endPosition = 5 ; const sut = new CodePosition ( startPosition , endPosition ) ; expect ( sut . startLine ) . to . equal ( startPosition ) ; expect ( sut . endLine ) . to . equal ( endPosition ) ; } ) ; it ( 'throws with negative start position' , ( ) => { const startPosition = - 1 ; const endPosition = 5 ; const getSut = ( ) => new CodePosition ( startPosition , endPosition ) ; expect ( getSut ) . to . throw ( 'Code cannot start in a negative line' ) ; } ) ; it ( 'throws with negative end position' , ( ) => { const startPosition = 1 ; const endPosition = - 5 ; const getSut = ( ) => new CodePosition ( startPosition , endPosition ) ; expect ( getSut ) . to . throw ( 'Code cannot end in a negative line' ) ; } ) ; it ( 'throws when start and end position is same' , ( ) => { const startPosition = 0 ; const endPosition = 0 ; const getSut = ( ) => new CodePosition ( startPosition , endPosition ) ; expect ( getSut ) . to . throw ( 'Empty code' ) ; } ) ; it ( 'throws when ends before start' , ( ) => { const startPosition = 3 ; const endPosition = 2 ; const getSut = ( ) => new CodePosition ( startPosition , endPosition ) ; expect ( getSut ) . to . throw ( 'End line cannot be less than start line' ) ; } ) ; } ) ; } ) ;