import "jest-styled-components" ; import * as React from "react" ; import { create } from "react-test-renderer" ; import ShallowRenderer from "react-test-renderer/shallow" ; import { App } from "." ; import { convertToObject } from "../../util/YmlUtils" ; import { swaggerJson_2_0 } from "./fixtures/SwaggerJson_2_0" ; import { swaggerYaml_2_0 } from "./fixtures/SwaggerYaml_2_0" ; import { swaggerYaml_3_0 } from "./fixtures/SwaggerYaml_3_0" ; describe ( "Shallow render test" , ( ) => { beforeAll ( ( ) => { console . warn = ( ) => undefined ; } ) ; it ( "shallow render and snapshot" , ( ) => { const renderer = ShallowRenderer . createRenderer ( ) ; const swaggerJson = "" ; renderer . render ( < App swaggerJson = { swaggerJson } / > ) ; const result = renderer . getRenderOutput ( ) ; expect ( result ) . toMatchSnapshot ( ) ; } ) ; } ) ; describe ( "Render test" , ( ) => { beforeAll ( ( ) => { console . warn = ( ) => undefined ; } ) ; it ( "invalid swagger" , ( ) => { const swaggerJson = "" ; const result = create ( < App swaggerJson = { swaggerJson } / > ) ; expect ( result ) . toMatchSnapshot ( ) ; } ) ; it ( "Swagger yaml 2.0" , ( ) => { const swaggerJson = convertToObject ( swaggerYaml_2_0 ) ; if ( ! swaggerJson ) { throw new Error ( "Invalid fixture" ) ; } const result = create ( < App swaggerJson = { swaggerJson } / > ) ; expect ( result ) . toMatchSnapshot ( ) ; } ) ; it ( "Swagger yaml 3.0" , ( ) => { const swaggerJson = convertToObject ( swaggerYaml_3_0 ) ; if ( ! swaggerJson ) { throw new Error ( "Invalid fixture" ) ; } const result = create ( < App swaggerJson = { swaggerJson } / > ) ; expect ( result ) . toMatchSnapshot ( ) ; } ) ; it ( "Swagger json 2.0" , ( ) => { const swaggerJson = convertToObject ( swaggerJson_2_0 ) ; if ( ! swaggerJson ) { throw new Error ( "Invalid fixture" ) ; } const result = create ( < App swaggerJson = { swaggerJson } / > ) ; expect ( result ) . toMatchSnapshot ( ) ; } ) ; } ) ;