mirror of
https://github.com/Redocly/redoc.git
synced 2025-06-24 14:43:04 +03:00
parent
a1aefa4123
commit
e76bcc3329
|
@ -16,6 +16,50 @@ describe('Spec Helper', () => {
|
||||||
expect(console.warn).toHaveBeenCalled();
|
expect(console.warn).toHaveBeenCalled();
|
||||||
(<jasmine.Spy>console.warn).and.callThrough();
|
(<jasmine.Spy>console.warn).and.callThrough();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('string', () => {
|
||||||
|
it('should calculate range for string with maxLength', () => {
|
||||||
|
let schema:any = {
|
||||||
|
type: 'string',
|
||||||
|
maxLength: 3
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaHelper.runInjectors(schema, schema, '#/');
|
||||||
|
schema._range.should.be.equal('<= 3 characters');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should calculate range for string with minLength', () => {
|
||||||
|
let schema:any = {
|
||||||
|
type: 'string',
|
||||||
|
minLength: 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaHelper.runInjectors(schema, schema, '#/');
|
||||||
|
schema._range.should.be.equal('>= 3 characters');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should calculate range for string with both max and minLength', () => {
|
||||||
|
let schema:any = {
|
||||||
|
type: 'string',
|
||||||
|
minLength: 3,
|
||||||
|
maxLength: 5
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaHelper.runInjectors(schema, schema, '#/');
|
||||||
|
schema._range.should.be.equal('[ 3 .. 5 ] characters');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should calculate range for string with equal max and minLength', () => {
|
||||||
|
let schema:any = {
|
||||||
|
type: 'string',
|
||||||
|
minLength: 5,
|
||||||
|
maxLength: 5
|
||||||
|
};
|
||||||
|
|
||||||
|
SchemaHelper.runInjectors(schema, schema, '#/');
|
||||||
|
schema._range.should.be.equal('5 characters');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('preprocessProperties', () => {
|
describe('preprocessProperties', () => {
|
||||||
|
|
|
@ -150,7 +150,11 @@ const injectors = {
|
||||||
inject: (injectTo, propertySchema = injectTo) => {
|
inject: (injectTo, propertySchema = injectTo) => {
|
||||||
var range;
|
var range;
|
||||||
if (propertySchema.minLength != undefined && propertySchema.maxLength != undefined) {
|
if (propertySchema.minLength != undefined && propertySchema.maxLength != undefined) {
|
||||||
|
if (propertySchema.minLength === propertySchema.maxLength) {
|
||||||
|
range = `${propertySchema.minLength}`;
|
||||||
|
} else {
|
||||||
range = `[ ${propertySchema.minLength} .. ${propertySchema.maxLength} ]`;
|
range = `[ ${propertySchema.minLength} .. ${propertySchema.maxLength} ]`;
|
||||||
|
}
|
||||||
} else if (propertySchema.maxLength != undefined) {
|
} else if (propertySchema.maxLength != undefined) {
|
||||||
range = '<= ' + propertySchema.maxLength;
|
range = '<= ' + propertySchema.maxLength;
|
||||||
} else if (propertySchema.minLength != undefined) {
|
} else if (propertySchema.minLength != undefined) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user