import { expect } from 'chai' ; import fs from 'fs-extra' ; import { messageConfig , readMessageConfigForTestingOnly , } from '../../../../src/lib/config' ; import { BasicScene } from '../../../lib/scenes' ; import { configureTest } from '../../../lib/utils' ; for ( const scene of [ new BasicScene ( ) ] ) { describe ( `(${ scene }): upgrade message` , function ( ) { configureTest ( this , scene ) ; it ( 'Sanity check - can read previously written message config' , ( ) => { const contents = 'Hello world!' ; const cliVersion = '0.0.0' ; messageConfig . setMessage ( { contents : contents , cliVersion : cliVersion , } ) ; const writtenMessageConfig = readMessageConfigForTestingOnly ( ) ; const writtenContents = writtenMessageConfig . getMessage ( ) ?. contents ; const wirttenCLIVersion = writtenMessageConfig . getMessage ( ) ?. cliVersion ; expect ( writtenContents === contents ) . to . be . true ; expect ( wirttenCLIVersion === cliVersion ) . to . be . true ; } ) ; it ( 'If no message, removes message config file' , ( ) => { messageConfig . setMessage ( undefined ) ; expect ( fs . existsSync ( messageConfig . path ( ) ) ) . to . be . false ; messageConfig . setMessage ( undefined ) ; expect ( fs . existsSync ( messageConfig . path ( ) ) ) . to . be . false ; } ) ; after ( ( ) => { if ( fs . existsSync ( messageConfig . path ( ) ) ) { fs . unlinkSync ( messageConfig . path ( ) ) ; } } ) ; } ) ; }