import * as path from 'path' ; import { Application } from 'spectron' ; import { assert } from 'chai' ; const electron = ( require as any ) ( 'electron' ) ; describe ( 'neovim element' , function ( ) { this . timeout ( 10000 ) ; before ( function ( ) { this . app = new Application ( { path : electron , args : [ path . join ( __dirname , '..' , '..' , '..' ) ] , env : { NODE_ENV : 'production' , } , } ) ; return this . app . start ( ) . then ( ( ) => this . app . client . pause ( 3000 ) ) ; } ) ; after ( function ( ) { if ( this . app . isRunning ( ) ) { return this . app . stop ( ) ; } } ) ; it ( 'can start without an error' , function ( ) { return this . app . client . getWindowCount ( ) . then ( ( c ) => assert . equal ( c , 1 ) ) . then ( ( ) => this . app . browserWindow . isVisible ( ) ) . then ( ( b ) => assert . isTrue ( b ) ) . then ( ( ) => this . app . webContents . getURL ( ) ) . then ( ( u ) => assert . ok ( u ) ) . then ( ( ) => this . app . client . execute ( ( ) => { const e = document . getElementById ( 'neovim' ) as any ; if ( ! e ) { return null ; } return e . editor . screen . ctx . getImageData ( 10 , 10 , 1 , 1 ) ; } ) ) . then ( ( returned ) => { const rgba = returned . value . data ; assert . equal ( rgba . length , 4 ) ; assert . isFalse ( rgba [ 0 ] === 255 && rgba [ 1 ] === 255 && rgba [ 2 ] === 255 ) ; } ) . then ( ( ) => this . app . client . getRenderProcessLogs ( ) ) . then ( ( logs ) => { for ( const log of logs ) { assert . notEqual ( log . level , 'error' , log . message ) ; } } ) . then ( ( ) => this . app . client . getMainProcessLogs ( ) ) . then ( ( logs ) => { const allowedErrors = [ 'net::ERR_FILE_NOT_FOUND' , 'Electron Security Warning' , 'Unhandled event:' , 'DevTools listening on' , 'HTML Imports is deprecated and will be removed in M73' , "'electron.screen' is deprecated" , ] ; const unexpectedLogs = logs . filter ( m => ! allowedErrors . some ( w => m . includes ( w ) ) ) . filter ( m => m !== '' ) ; assert . equal ( unexpectedLogs . length , 0 , `'${ unexpectedLogs }'` ) ; } ) ; } ) ; } ) ;