import { CompositeDisposable , Disposable } from 'ts-disposables' ; import { DriverState } from 'omnisharp-client' ; import { Observable } from 'rxjs' ; import { SolutionManager } from '../lib/server/solution-manager' ; export function setupFeature ( features , unitTestMode = true ) { let cd ; beforeEach ( function ( ) { cd = new CompositeDisposable ( ) ; SolutionManager . _unitTestMode_ = unitTestMode ; SolutionManager . _kick_in_the_pants_ = true ; atom . config . set ( 'omnisharp-atom:feature-white-list' , true ) ; atom . config . set ( 'omnisharp-atom:feature-list' , features ) ; return atom . packages . activatePackage ( 'language-csharp' ) . then ( ( ) => atom . packages . activatePackage ( 'omnisharp-atom' ) ) . then ( ( pack ) => pack . mainModule . _activated . delay ( 200 ) . toPromise ( ) ) ; } ) ; afterEach ( function ( ) { atom . packages . deactivatePackage ( 'omnisharp-atom' ) ; atom . packages . deactivatePackage ( 'language-csharp' ) ; atom . config . set ( 'omnisharp-atom:feature-white-list' , undefined ) ; atom . config . set ( 'omnisharp-atom:feature-list' , undefined ) ; SolutionManager . _unitTestMode_ = false ; SolutionManager . _kick_in_the_pants_ = false ; cd . dispose ( ) ; } ) ; } export function restoreBuffers ( ) { return Disposable . empty ; } export function openEditor ( file ) { return Observable . fromPromise < Atom . TextEditor > ( < any > atom . workspace . open ( file ) ) . flatMap ( editor => SolutionManager . getSolutionForEditor ( editor ) . map ( solution => ( { editor , solution } ) ) ) . flatMap ( ( { editor , solution } ) => solution . state . startWith ( solution . currentState ) . map ( state => ( { editor , solution , state : state } ) ) ) . filter ( z => z . state === DriverState . Connected ) . take ( 1 ) . delay ( 350 ) ; }