mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-08 22:24:54 +03:00
Add callback model test
This commit is contained in:
parent
44ce9c5ddb
commit
43142d5384
64
src/services/__tests__/fixtures/callback.json
Normal file
64
src/services/__tests__/fixtures/callback.json
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
{
|
||||||
|
"openapi": "3.0.0",
|
||||||
|
"info": {
|
||||||
|
"version": "1.0",
|
||||||
|
"title": "Foo"
|
||||||
|
},
|
||||||
|
"components": {
|
||||||
|
"callbacks": {
|
||||||
|
"Test": {
|
||||||
|
"post": {
|
||||||
|
"operationId": "testCallback",
|
||||||
|
"description": "Test callback.",
|
||||||
|
"requestBody": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"title": "TestTitle",
|
||||||
|
"type": "object",
|
||||||
|
"description": "Test description",
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The type of response.",
|
||||||
|
"enum": [
|
||||||
|
"TestResponse.Complete"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"FAILURE",
|
||||||
|
"SUCCESS"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"status"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "X-Test-Header",
|
||||||
|
"in": "header",
|
||||||
|
"required": true,
|
||||||
|
"example": "1",
|
||||||
|
"description": "This is a test header parameter",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"204": {
|
||||||
|
"description": "Test response."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
src/services/__tests__/models/Callback.test.ts
Normal file
26
src/services/__tests__/models/Callback.test.ts
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import { CallbackModel } from '../../models/Callback';
|
||||||
|
import { OpenAPIParser } from '../../OpenAPIParser';
|
||||||
|
import { RedocNormalizedOptions } from '../../RedocNormalizedOptions';
|
||||||
|
|
||||||
|
const opts = new RedocNormalizedOptions({});
|
||||||
|
|
||||||
|
describe('Models', () => {
|
||||||
|
describe('CallbackModel', () => {
|
||||||
|
let parser;
|
||||||
|
const spec = require('../fixtures/callback.json');
|
||||||
|
parser = new OpenAPIParser(spec, undefined, opts);
|
||||||
|
|
||||||
|
test('basic callback details', () => {
|
||||||
|
const callback = new CallbackModel(
|
||||||
|
parser,
|
||||||
|
'Test.Callback',
|
||||||
|
{ $ref: '#/components/callbacks/Test' },
|
||||||
|
opts,
|
||||||
|
);
|
||||||
|
expect(callback.name).toEqual('Test.Callback');
|
||||||
|
expect(callback.operations.length).toEqual(0);
|
||||||
|
expect(callback.paths).toBeDefined();
|
||||||
|
expect(callback.expanded).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user