import { Context } from '@loopback/core' ; import { expect } from '@loopback/testlab' ; import { ContextGraph } from '../..' ; import { renderGraph } from '../../visualizer' ; describe ( 'Visualizer' , ( ) => { let app ; let server ; beforeEach ( givenContexts ) ; it ( 'creates a dot graph with bindings' , async function ( this ) { if ( ( process . platform as string ) === 'os390' ) return this . skip ( ) ; server . bind ( 'port' ) . to ( 3000 ) ; app . bind ( 'now' ) . toDynamicValue ( ( ) => new Date ( ) ) ; const json = server . inspect ( ) ; const graph = new ContextGraph ( json ) ; const dot = graph . render ( ) ; const svg = await renderGraph ( dot , { engine : 'fdp' , format : 'svg' } ) ; expect ( svg ) . to . match ( /^<\?xml/ ) ; expect ( svg ) . to . match ( /<svg / ) ; } ) ; function givenContexts ( ) { app = new Context ( 'app' ) ; server = new Context ( app , 'server' ) ; } } ) ;