mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-31 10:04:08 +03:00
Fix unit tests
This commit is contained in:
parent
a94afe5f2d
commit
9389d7dc15
|
@ -10,7 +10,7 @@ h2, h3 {
|
|||
}
|
||||
|
||||
:host h2 {
|
||||
margin-top: 40px;
|
||||
padding-top: 40px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { Component, ChangeDetectionStrategy, OnInit, HostListener } from '@angular/core';
|
||||
import { SpecManager, BaseComponent } from '../base';
|
||||
|
||||
import { ComponentParser } from '../../services/';
|
||||
import { ComponentParser } from '../../services/component-parser.service';
|
||||
|
||||
const AUTH_TYPES = {
|
||||
'oauth2': 'OAuth2',
|
||||
|
|
|
@ -98,6 +98,7 @@ describe('Menu service', () => {
|
|||
selector: 'test-app',
|
||||
template:
|
||||
`<div id='parent' style='height: 500px; overflow:auto'>
|
||||
<api-info></api-info>
|
||||
<methods-list></methods-list>
|
||||
</div>`
|
||||
})
|
||||
|
|
|
@ -145,6 +145,7 @@ export class MenuService {
|
|||
let sectionId = ptr.split('/')[0];
|
||||
ptr = ptr.substr(sectionId.length) || null;
|
||||
sectionId = namespace + (sectionId ? '/' + sectionId : '');
|
||||
$el = this.getMethodElByPtr(ptr, sectionId);
|
||||
} else {
|
||||
$el = this.getMethodElByPtr(null, namespace + '/' + ptr);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@ import { Injectable } from '@angular/core';
|
|||
import * as slugify from 'slugify';
|
||||
import * as Remarkable from 'remarkable';
|
||||
|
||||
import { SecurityDefinitions } from '../components/';
|
||||
|
||||
declare var Prism: any;
|
||||
const md = new Remarkable({
|
||||
html: true,
|
||||
|
@ -28,15 +26,12 @@ interface HeadersHandler {
|
|||
|
||||
@Injectable()
|
||||
export class MdRenderer {
|
||||
public firstLevelHeadings: string[] = [];
|
||||
|
||||
private _origRules:any = {};
|
||||
private _preProcessors:Function[] = [];
|
||||
|
||||
public firstLevelHeadings: string[] = [];
|
||||
constructor(private raw: boolean = false) {
|
||||
// TODO
|
||||
if (!raw) {
|
||||
this.addPreprocessor(SecurityDefinitions.insertTagIntoDescription);
|
||||
}
|
||||
}
|
||||
|
||||
addPreprocessor(p: Function) {
|
||||
|
|
|
@ -5,7 +5,7 @@ import { JsonPointer } from './JsonPointer';
|
|||
import { parse as urlParse, resolve as urlResolve } from 'url';
|
||||
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||
|
||||
import { MdRenderer } from './';
|
||||
import { MdRenderer } from './md-renderer';
|
||||
|
||||
export class SpecManager {
|
||||
public _schema: any = {};
|
||||
|
@ -77,6 +77,10 @@ export class SpecManager {
|
|||
preprocess() {
|
||||
let mdRender = new MdRenderer();
|
||||
if (!this._schema.info.description) this._schema.info.description = '';
|
||||
if (this._schema.securityDefinitions) {
|
||||
let SecurityDefinitions = require('../components/').SecurityDefinitions;
|
||||
mdRender.addPreprocessor(SecurityDefinitions.insertTagIntoDescription);
|
||||
}
|
||||
this._schema.info['x-redoc-html-description'] = mdRender.renderMd(this._schema.info.description);
|
||||
this._schema.info['x-redoc-markdown-headers'] = mdRender.firstLevelHeadings;
|
||||
}
|
||||
|
|
|
@ -22,11 +22,14 @@ var TestBed = require('@angular/core/testing').TestBed;
|
|||
var ErrorHandler = require('@angular/core').ErrorHandler;
|
||||
var BrowserDynamicTestingModule = require('@angular/platform-browser-dynamic/testing').BrowserDynamicTestingModule;
|
||||
var platformBrowserDynamicTesting = require('@angular/platform-browser-dynamic/testing').platformBrowserDynamicTesting;
|
||||
var services = require('../lib/services/index');
|
||||
|
||||
var SpecManager = require('../lib/utils/spec-manager').SpecManager;
|
||||
var services = require('../lib/services/index');
|
||||
var REDOC_PIPES = require('../lib/utils/pipes').REDOC_PIPES;
|
||||
var REDOC_COMMON_DIRECTIVES = require('../lib/shared/components/index').REDOC_COMMON_DIRECTIVES;
|
||||
var REDOC_DIRECTIVES = require('../lib/components/index').REDOC_DIRECTIVES;
|
||||
var sharedComponents = require('../lib/shared/components/');
|
||||
var REDOC_COMMON_DIRECTIVES = sharedComponents.REDOC_COMMON_DIRECTIVES;
|
||||
var components = require('../lib/components/');
|
||||
var REDOC_DIRECTIVES = components.REDOC_DIRECTIVES;
|
||||
|
||||
TestBed.initTestEnvironment(
|
||||
BrowserDynamicTestingModule,
|
||||
|
@ -43,10 +46,18 @@ beforeEach(function() {
|
|||
services.MenuService,
|
||||
services.WarningsService,
|
||||
services.OptionsService,
|
||||
{ provide: ErrorHandler, useClass: services.CustomErrorHandler }
|
||||
services.ComponentParser,
|
||||
services.ContentProjector,
|
||||
{ provide: ErrorHandler, useClass: services.CustomErrorHandler },
|
||||
{ provide: services.COMPONENT_PARSER_ALLOWED, useValue: { 'security-definitions': components.SecurityDefinitions }}
|
||||
],
|
||||
declarations: [REDOC_PIPES, REDOC_DIRECTIVES, REDOC_COMMON_DIRECTIVES]
|
||||
});
|
||||
TestBed.overrideModule(BrowserDynamicTestingModule, {
|
||||
set: {
|
||||
entryComponents: [ sharedComponents.DynamicNg2Wrapper, components.SecurityDefinitions ]
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user