mirror of
				https://github.com/Redocly/redoc.git
				synced 2025-10-31 07:47:29 +03:00 
			
		
		
		
	tests: filter out options object from snapshorts
This commit is contained in:
		
							parent
							
								
									3aab2d97d3
								
							
						
					
					
						commit
						a6ae43a136
					
				|  | @ -32,6 +32,7 @@ | ||||||
|     "@types/enzyme-to-json": "^1.5.0", |     "@types/enzyme-to-json": "^1.5.0", | ||||||
|     "@types/jest": "^22.1.0", |     "@types/jest": "^22.1.0", | ||||||
|     "@types/json-pointer": "^1.0.30", |     "@types/json-pointer": "^1.0.30", | ||||||
|  |     "@types/lodash": "^4.14.98", | ||||||
|     "@types/prismjs": "^1.6.4", |     "@types/prismjs": "^1.6.4", | ||||||
|     "@types/prop-types": "^15.5.2", |     "@types/prop-types": "^15.5.2", | ||||||
|     "@types/react": "^16.0.30", |     "@types/react": "^16.0.30", | ||||||
|  | @ -52,6 +53,7 @@ | ||||||
|     "enzyme-to-json": "^3.2.2", |     "enzyme-to-json": "^3.2.2", | ||||||
|     "html-webpack-plugin": "^2.30.1", |     "html-webpack-plugin": "^2.30.1", | ||||||
|     "jest": "^22.1.4", |     "jest": "^22.1.4", | ||||||
|  |     "lodash": "^4.17.4", | ||||||
|     "mobx-react-devtools": "^4.2.15", |     "mobx-react-devtools": "^4.2.15", | ||||||
|     "prettier": "^1.5.3", |     "prettier": "^1.5.3", | ||||||
|     "prettier-eslint": "^8.8.1", |     "prettier-eslint": "^8.8.1", | ||||||
|  |  | ||||||
|  | @ -1,8 +1,10 @@ | ||||||
| import { RedocNormalizedOptions } from '../../../services/RedocNormalizedOptions'; |  | ||||||
| import * as React from 'react'; | import * as React from 'react'; | ||||||
| import { shallow } from 'enzyme'; | import { shallow } from 'enzyme'; | ||||||
| import toJson from 'enzyme-to-json'; | import toJson from 'enzyme-to-json'; | ||||||
| 
 | 
 | ||||||
|  | import { filterPropsDeep } from '../../../utils/test-utils'; | ||||||
|  | 
 | ||||||
|  | import { RedocNormalizedOptions } from '../../../services/RedocNormalizedOptions'; | ||||||
| import { OpenAPIParser, SchemaModel } from '../../../services'; | import { OpenAPIParser, SchemaModel } from '../../../services'; | ||||||
| import { Schema } from '../Schema'; | import { Schema } from '../Schema'; | ||||||
| import { ObjectSchema } from '../ObjectSchema'; | import { ObjectSchema } from '../ObjectSchema'; | ||||||
|  | @ -43,7 +45,7 @@ describe('Components', () => { | ||||||
|             }} |             }} | ||||||
|           />, |           />, | ||||||
|         ); |         ); | ||||||
|         expect(toJson(schemaView)).toMatchSnapshot(); |         expect(filterPropsDeep(toJson(schemaView), ['field.schema.options'])).toMatchSnapshot(); | ||||||
|       }); |       }); | ||||||
|     }); |     }); | ||||||
|   }); |   }); | ||||||
|  |  | ||||||
|  | @ -832,73 +832,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView | ||||||
|             "isCircular": undefined, |             "isCircular": undefined, | ||||||
|             "isPrimitive": true, |             "isPrimitive": true, | ||||||
|             "nullable": false, |             "nullable": false, | ||||||
|             "options": RedocNormalizedOptions { |             "options": "<<<filtered>>>", | ||||||
|               "expandResponses": Object {}, |  | ||||||
|               "hideHostname": false, |  | ||||||
|               "nativeScrollbars": false, |  | ||||||
|               "noAutoAuth": false, |  | ||||||
|               "pathInMiddlePanel": false, |  | ||||||
|               "requiredPropsFirst": false, |  | ||||||
|               "scrollYOffset": [Function], |  | ||||||
|               "theme": Object { |  | ||||||
|                 "baseFont": Object { |  | ||||||
|                   "family": "Roboto, sans-serif", |  | ||||||
|                   "lineHeight": "1.5", |  | ||||||
|                   "optimizeSpeed": true, |  | ||||||
|                   "size": "14px", |  | ||||||
|                   "smoothing": "antialiased", |  | ||||||
|                   "weight": "300", |  | ||||||
|                 }, |  | ||||||
|                 "code": Object { |  | ||||||
|                   "fontFamily": "Courier, monospace", |  | ||||||
|                   "fontSize": "13px", |  | ||||||
|                 }, |  | ||||||
|                 "colors": Object { |  | ||||||
|                   "error": "#e53935", |  | ||||||
|                   "http": Object { |  | ||||||
|                     "basic": "#999", |  | ||||||
|                     "delete": "#e27a7a", |  | ||||||
|                     "get": "#6bbd5b", |  | ||||||
|                     "link": "#31bbb6", |  | ||||||
|                     "options": "#d3ca12", |  | ||||||
|                     "patch": "#e09d43", |  | ||||||
|                     "post": "#248fb2", |  | ||||||
|                     "put": "#9b708b", |  | ||||||
|                   }, |  | ||||||
|                   "info": "skyblue", |  | ||||||
|                   "main": "#32329f", |  | ||||||
|                   "redirect": "orange", |  | ||||||
|                   "success": "#00aa13", |  | ||||||
|                   "text": "#263238", |  | ||||||
|                   "warning": "#f1c400", |  | ||||||
|                 }, |  | ||||||
|                 "headingsFont": Object { |  | ||||||
|                   "family": "Montserrat, sans-serif", |  | ||||||
|                 }, |  | ||||||
|                 "links": Object { |  | ||||||
|                   "color": undefined, |  | ||||||
|                   "hover": undefined, |  | ||||||
|                   "visited": undefined, |  | ||||||
|                 }, |  | ||||||
|                 "logo": Object { |  | ||||||
|                   "maxHeight": "120px", |  | ||||||
|                 }, |  | ||||||
|                 "menu": Object { |  | ||||||
|                   "backgroundColor": "#fafafa", |  | ||||||
|                   "width": "260px", |  | ||||||
|                 }, |  | ||||||
|                 "rightPanel": Object { |  | ||||||
|                   "backgroundColor": "#263238", |  | ||||||
|                   "width": 40, |  | ||||||
|                 }, |  | ||||||
|                 "schemaView": Object { |  | ||||||
|                   "defaultDetailsWidth": "75%", |  | ||||||
|                   "linesColor": "#7f99cf", |  | ||||||
|                 }, |  | ||||||
|                 "spacingUnit": 20, |  | ||||||
|               }, |  | ||||||
|               "untrustedSpec": false, |  | ||||||
|             }, |  | ||||||
|             "pattern": undefined, |             "pattern": undefined, | ||||||
|             "rawSchema": Object { |             "rawSchema": Object { | ||||||
|               "default": undefined, |               "default": undefined, | ||||||
|  | @ -937,73 +871,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView | ||||||
|             "isCircular": undefined, |             "isCircular": undefined, | ||||||
|             "isPrimitive": true, |             "isPrimitive": true, | ||||||
|             "nullable": false, |             "nullable": false, | ||||||
|             "options": RedocNormalizedOptions { |             "options": "<<<filtered>>>", | ||||||
|               "expandResponses": Object {}, |  | ||||||
|               "hideHostname": false, |  | ||||||
|               "nativeScrollbars": false, |  | ||||||
|               "noAutoAuth": false, |  | ||||||
|               "pathInMiddlePanel": false, |  | ||||||
|               "requiredPropsFirst": false, |  | ||||||
|               "scrollYOffset": [Function], |  | ||||||
|               "theme": Object { |  | ||||||
|                 "baseFont": Object { |  | ||||||
|                   "family": "Roboto, sans-serif", |  | ||||||
|                   "lineHeight": "1.5", |  | ||||||
|                   "optimizeSpeed": true, |  | ||||||
|                   "size": "14px", |  | ||||||
|                   "smoothing": "antialiased", |  | ||||||
|                   "weight": "300", |  | ||||||
|                 }, |  | ||||||
|                 "code": Object { |  | ||||||
|                   "fontFamily": "Courier, monospace", |  | ||||||
|                   "fontSize": "13px", |  | ||||||
|                 }, |  | ||||||
|                 "colors": Object { |  | ||||||
|                   "error": "#e53935", |  | ||||||
|                   "http": Object { |  | ||||||
|                     "basic": "#999", |  | ||||||
|                     "delete": "#e27a7a", |  | ||||||
|                     "get": "#6bbd5b", |  | ||||||
|                     "link": "#31bbb6", |  | ||||||
|                     "options": "#d3ca12", |  | ||||||
|                     "patch": "#e09d43", |  | ||||||
|                     "post": "#248fb2", |  | ||||||
|                     "put": "#9b708b", |  | ||||||
|                   }, |  | ||||||
|                   "info": "skyblue", |  | ||||||
|                   "main": "#32329f", |  | ||||||
|                   "redirect": "orange", |  | ||||||
|                   "success": "#00aa13", |  | ||||||
|                   "text": "#263238", |  | ||||||
|                   "warning": "#f1c400", |  | ||||||
|                 }, |  | ||||||
|                 "headingsFont": Object { |  | ||||||
|                   "family": "Montserrat, sans-serif", |  | ||||||
|                 }, |  | ||||||
|                 "links": Object { |  | ||||||
|                   "color": undefined, |  | ||||||
|                   "hover": undefined, |  | ||||||
|                   "visited": undefined, |  | ||||||
|                 }, |  | ||||||
|                 "logo": Object { |  | ||||||
|                   "maxHeight": "120px", |  | ||||||
|                 }, |  | ||||||
|                 "menu": Object { |  | ||||||
|                   "backgroundColor": "#fafafa", |  | ||||||
|                   "width": "260px", |  | ||||||
|                 }, |  | ||||||
|                 "rightPanel": Object { |  | ||||||
|                   "backgroundColor": "#263238", |  | ||||||
|                   "width": 40, |  | ||||||
|                 }, |  | ||||||
|                 "schemaView": Object { |  | ||||||
|                   "defaultDetailsWidth": "75%", |  | ||||||
|                   "linesColor": "#7f99cf", |  | ||||||
|                 }, |  | ||||||
|                 "spacingUnit": 20, |  | ||||||
|               }, |  | ||||||
|               "untrustedSpec": false, |  | ||||||
|             }, |  | ||||||
|             "pattern": undefined, |             "pattern": undefined, | ||||||
|             "rawSchema": Object { |             "rawSchema": Object { | ||||||
|               "default": undefined, |               "default": undefined, | ||||||
|  | @ -1165,73 +1033,7 @@ exports[`Components SchemaView discriminator should correctly render discriminat | ||||||
|             "isCircular": undefined, |             "isCircular": undefined, | ||||||
|             "isPrimitive": true, |             "isPrimitive": true, | ||||||
|             "nullable": false, |             "nullable": false, | ||||||
|             "options": RedocNormalizedOptions { |             "options": "<<<filtered>>>", | ||||||
|               "expandResponses": Object {}, |  | ||||||
|               "hideHostname": false, |  | ||||||
|               "nativeScrollbars": false, |  | ||||||
|               "noAutoAuth": false, |  | ||||||
|               "pathInMiddlePanel": false, |  | ||||||
|               "requiredPropsFirst": false, |  | ||||||
|               "scrollYOffset": [Function], |  | ||||||
|               "theme": Object { |  | ||||||
|                 "baseFont": Object { |  | ||||||
|                   "family": "Roboto, sans-serif", |  | ||||||
|                   "lineHeight": "1.5", |  | ||||||
|                   "optimizeSpeed": true, |  | ||||||
|                   "size": "14px", |  | ||||||
|                   "smoothing": "antialiased", |  | ||||||
|                   "weight": "300", |  | ||||||
|                 }, |  | ||||||
|                 "code": Object { |  | ||||||
|                   "fontFamily": "Courier, monospace", |  | ||||||
|                   "fontSize": "13px", |  | ||||||
|                 }, |  | ||||||
|                 "colors": Object { |  | ||||||
|                   "error": "#e53935", |  | ||||||
|                   "http": Object { |  | ||||||
|                     "basic": "#999", |  | ||||||
|                     "delete": "#e27a7a", |  | ||||||
|                     "get": "#6bbd5b", |  | ||||||
|                     "link": "#31bbb6", |  | ||||||
|                     "options": "#d3ca12", |  | ||||||
|                     "patch": "#e09d43", |  | ||||||
|                     "post": "#248fb2", |  | ||||||
|                     "put": "#9b708b", |  | ||||||
|                   }, |  | ||||||
|                   "info": "skyblue", |  | ||||||
|                   "main": "#32329f", |  | ||||||
|                   "redirect": "orange", |  | ||||||
|                   "success": "#00aa13", |  | ||||||
|                   "text": "#263238", |  | ||||||
|                   "warning": "#f1c400", |  | ||||||
|                 }, |  | ||||||
|                 "headingsFont": Object { |  | ||||||
|                   "family": "Montserrat, sans-serif", |  | ||||||
|                 }, |  | ||||||
|                 "links": Object { |  | ||||||
|                   "color": undefined, |  | ||||||
|                   "hover": undefined, |  | ||||||
|                   "visited": undefined, |  | ||||||
|                 }, |  | ||||||
|                 "logo": Object { |  | ||||||
|                   "maxHeight": "120px", |  | ||||||
|                 }, |  | ||||||
|                 "menu": Object { |  | ||||||
|                   "backgroundColor": "#fafafa", |  | ||||||
|                   "width": "260px", |  | ||||||
|                 }, |  | ||||||
|                 "rightPanel": Object { |  | ||||||
|                   "backgroundColor": "#263238", |  | ||||||
|                   "width": 40, |  | ||||||
|                 }, |  | ||||||
|                 "schemaView": Object { |  | ||||||
|                   "defaultDetailsWidth": "75%", |  | ||||||
|                   "linesColor": "#7f99cf", |  | ||||||
|                 }, |  | ||||||
|                 "spacingUnit": 20, |  | ||||||
|               }, |  | ||||||
|               "untrustedSpec": false, |  | ||||||
|             }, |  | ||||||
|             "pattern": undefined, |             "pattern": undefined, | ||||||
|             "rawSchema": Object { |             "rawSchema": Object { | ||||||
|               "default": undefined, |               "default": undefined, | ||||||
|  | @ -1277,73 +1079,7 @@ exports[`Components SchemaView discriminator should correctly render discriminat | ||||||
|             "isCircular": undefined, |             "isCircular": undefined, | ||||||
|             "isPrimitive": true, |             "isPrimitive": true, | ||||||
|             "nullable": false, |             "nullable": false, | ||||||
|             "options": RedocNormalizedOptions { |             "options": "<<<filtered>>>", | ||||||
|               "expandResponses": Object {}, |  | ||||||
|               "hideHostname": false, |  | ||||||
|               "nativeScrollbars": false, |  | ||||||
|               "noAutoAuth": false, |  | ||||||
|               "pathInMiddlePanel": false, |  | ||||||
|               "requiredPropsFirst": false, |  | ||||||
|               "scrollYOffset": [Function], |  | ||||||
|               "theme": Object { |  | ||||||
|                 "baseFont": Object { |  | ||||||
|                   "family": "Roboto, sans-serif", |  | ||||||
|                   "lineHeight": "1.5", |  | ||||||
|                   "optimizeSpeed": true, |  | ||||||
|                   "size": "14px", |  | ||||||
|                   "smoothing": "antialiased", |  | ||||||
|                   "weight": "300", |  | ||||||
|                 }, |  | ||||||
|                 "code": Object { |  | ||||||
|                   "fontFamily": "Courier, monospace", |  | ||||||
|                   "fontSize": "13px", |  | ||||||
|                 }, |  | ||||||
|                 "colors": Object { |  | ||||||
|                   "error": "#e53935", |  | ||||||
|                   "http": Object { |  | ||||||
|                     "basic": "#999", |  | ||||||
|                     "delete": "#e27a7a", |  | ||||||
|                     "get": "#6bbd5b", |  | ||||||
|                     "link": "#31bbb6", |  | ||||||
|                     "options": "#d3ca12", |  | ||||||
|                     "patch": "#e09d43", |  | ||||||
|                     "post": "#248fb2", |  | ||||||
|                     "put": "#9b708b", |  | ||||||
|                   }, |  | ||||||
|                   "info": "skyblue", |  | ||||||
|                   "main": "#32329f", |  | ||||||
|                   "redirect": "orange", |  | ||||||
|                   "success": "#00aa13", |  | ||||||
|                   "text": "#263238", |  | ||||||
|                   "warning": "#f1c400", |  | ||||||
|                 }, |  | ||||||
|                 "headingsFont": Object { |  | ||||||
|                   "family": "Montserrat, sans-serif", |  | ||||||
|                 }, |  | ||||||
|                 "links": Object { |  | ||||||
|                   "color": undefined, |  | ||||||
|                   "hover": undefined, |  | ||||||
|                   "visited": undefined, |  | ||||||
|                 }, |  | ||||||
|                 "logo": Object { |  | ||||||
|                   "maxHeight": "120px", |  | ||||||
|                 }, |  | ||||||
|                 "menu": Object { |  | ||||||
|                   "backgroundColor": "#fafafa", |  | ||||||
|                   "width": "260px", |  | ||||||
|                 }, |  | ||||||
|                 "rightPanel": Object { |  | ||||||
|                   "backgroundColor": "#263238", |  | ||||||
|                   "width": 40, |  | ||||||
|                 }, |  | ||||||
|                 "schemaView": Object { |  | ||||||
|                   "defaultDetailsWidth": "75%", |  | ||||||
|                   "linesColor": "#7f99cf", |  | ||||||
|                 }, |  | ||||||
|                 "spacingUnit": 20, |  | ||||||
|               }, |  | ||||||
|               "untrustedSpec": false, |  | ||||||
|             }, |  | ||||||
|             "pattern": undefined, |             "pattern": undefined, | ||||||
|             "rawSchema": Object { |             "rawSchema": Object { | ||||||
|               "default": undefined, |               "default": undefined, | ||||||
|  |  | ||||||
							
								
								
									
										29
									
								
								src/utils/test-utils.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/utils/test-utils.ts
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | ||||||
|  | import { instanceOf } from 'prop-types'; | ||||||
|  | import { RedocNormalizedOptions } from '../services/RedocNormalizedOptions'; | ||||||
|  | import { set, has } from 'lodash'; | ||||||
|  | 
 | ||||||
|  | function traverseComponent(root, fn) { | ||||||
|  |   if (!root) return; | ||||||
|  | 
 | ||||||
|  |   fn(root); | ||||||
|  | 
 | ||||||
|  |   if (root.children) { | ||||||
|  |     for (let child of root.children) { | ||||||
|  |       traverseComponent(child, fn); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export function filterPropsDeep<T extends Object>(component: T, paths: string[]): T { | ||||||
|  |   traverseComponent(component, comp => { | ||||||
|  |     if (comp.props) { | ||||||
|  |       for (const path of paths) { | ||||||
|  |         if (has(comp.props, path)) { | ||||||
|  |           set(comp.props, path, '<<<filtered>>>'); | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   return component; | ||||||
|  | } | ||||||
|  | @ -40,7 +40,7 @@ | ||||||
|     "@types/chai" "*" |     "@types/chai" "*" | ||||||
|     "@types/jquery" "*" |     "@types/jquery" "*" | ||||||
| 
 | 
 | ||||||
| "@types/chai@4.0.8", "@types/chai@*": | "@types/chai@*", "@types/chai@4.0.8": | ||||||
|   version "4.0.8" |   version "4.0.8" | ||||||
|   resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.0.8.tgz#d27600e9ba2f371e08695d90a0fe0408d89c7be7" |   resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.0.8.tgz#d27600e9ba2f371e08695d90a0fe0408d89c7be7" | ||||||
| 
 | 
 | ||||||
|  | @ -91,6 +91,10 @@ | ||||||
|   version "4.14.87" |   version "4.14.87" | ||||||
|   resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.87.tgz#55f92183b048c2c64402afe472f8333f4e319a6b" |   resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.87.tgz#55f92183b048c2c64402afe472f8333f4e319a6b" | ||||||
| 
 | 
 | ||||||
|  | "@types/lodash@^4.14.98": | ||||||
|  |   version "4.14.98" | ||||||
|  |   resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.98.tgz#aaf012ae443e657e7885e605a4c1b340db160609" | ||||||
|  | 
 | ||||||
| "@types/minimatch@3.0.1": | "@types/minimatch@3.0.1": | ||||||
|   version "3.0.1" |   version "3.0.1" | ||||||
|   resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.1.tgz#b683eb60be358304ef146f5775db4c0e3696a550" |   resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.1.tgz#b683eb60be358304ef146f5775db4c0e3696a550" | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user